Example Shared Library Makefile - Feedback Requested

7 posts / 0 new
Last post
Belxjander
Belxjander's picture
Offline
Last seen: 8 years 3 months ago
Joined: 2011-02-25 11:53
Example Shared Library Makefile - Feedback Requested

Is anyone willing to share an existing GCC using Makefile?

I know I can do the C code sections for what I want...
but I am dealing with the AmigaOS4.x changes from 3.x as somewhat new,

and I am also dealing with the GCC environment as new as well.

maybe what I am asking is unclear?

-「edit」-
I've managed to dig pieces of Makefiles out of the OS4 development kit,
but for the Makefile I have written to use myself I would like it to be checked out.
along with a basic "empty.library" template skeleton that I have used before for AOS3.x
if there is anything else special other than adding the Interfaces for the libraries?

Feedback would be appreciated:
all this work will be public and available as a working example for building
multi-target ( AOS4.x + AROS ) Shared Libraries for Amiga systems using GCC.
-「/edit」-

kas1e
kas1e's picture
Offline
Last seen: 1 year 5 months ago
Joined: 2010-11-30 15:30
As no one answer, i will be

As no one answer, i will be the brave one :) , so:

As i understand you need to know what Makefiles is it at all, and how they structured when you do your code for GCC? If so, then you can read any documentation in the net which describe Makefiles format (as its absolutly non amigaos4 specific, its the same as on linuxes and any other oses where GCC are used). Just type in google "gcc makefiles format" and there is a lot of links and explaining of how "make" works and how makefiles structured.

Then, as i understand you want to know how to construct Makefile which will build for you shared library ? Then all what you need to know its how to make a shared library for os4, and just put necessary flags to Makefile (i.e. there is no special makefiles for shared libs, makefiles are makefiles, and what you put in it based only on what you want to do). There can't be some 100% the same makefile which will works for every shared library which one want to create (all the libs its different set of sources of course, all of them compiles with different flags, and linking done differently, in matter of how and what you want to do).

Makefiles do the same as you can do via some bat-scripts: its just in some way constructed, but in end, its just compile and link for you sources and objects which you need, with the necessary flags and options. You even can not use makefiles at all if your project are small.

For the learning purposes you can check Salas00's ptplay.library port from os4depot (download it here). Which come with all the sources and Makefile, where you can find what kind of flags are provided to compiler and to linker in makefiles, and how to code shared library for os4 at all.

Rigo
Rigo's picture
Offline
Last seen: 1 year 10 months ago
Joined: 2011-01-24 21:55
Check out idltool which is

Check out idltool which is included with the SDK. Basically you generate a simple XML file which describes your library, then idltool will create all the files you need, then just fill in the functions. It's about as easy as it gets.

Simon

Belxjander
Belxjander's picture
Offline
Last seen: 8 years 3 months ago
Joined: 2011-02-25 11:53
using idltool has the

using idltool has the pre-requisite of running an Amiga OS 4.x system, this is a luxury I do not currently have (I am still working toward changing this)

so writing a Makefile myself and getting the options correct is like trying to play darts blindfolded with no idea where the board actually is...

I am after an already written one to compare against what I have done for myself so far
as I still feel I have missed something.

And I find it seriously uncomfortable in releasing code without being clear about that.

the "use idltool"/"use genmodule" suggestions while helpful are in themselves problematic
as I am a *returning* developer who has to learn about the AOS4 differences from AOS3
and earlier to make functional code.

so far I am certain I have messed up the options somewhere, especially as I want to write
entirely newlib based code where possible (clib2 if I must).

dealing with AmiDevCpp so far has been next to futile as the examples are based on the
assumption of writing application or commodity programs and not system components.

Where I am more interested in expanding what the OS itself can do with as minimal changes
to the OS itself as I can get away with.

Belxjander
Belxjander's picture
Offline
Last seen: 8 years 3 months ago
Joined: 2011-02-25 11:53
no... you actually missed the

no... you actually missed the entire point,

I know how to structure a Makefile and all the documentation *about* a Makefile
is entirely different to actually having a written *example* showing quite clearly
a functional demonstration.

Thank you for referring to an openly available library that is already ported,
as this is the kind of material I have been after...

[edit]again this is a VBCC Makefile, not GCC, Ive been looking for GCC examples[/edit]

it won't matter how many times I read about Makefiles and how simple they are,
without an example that is working, its all academic.

I also know that GCC and VBCC both come with the AOS4.x SDK however I would prefer
to have a working GCC usage for building a Shared Library.

so it appears that I will be waiting for when I get my own AOS4.x machine anyway.

No matter how well meaning your intentions, you still missed the target :|

salass00
salass00's picture
Offline
Last seen: 1 year 1 month ago
Joined: 2011-02-03 11:27
Makefile from

Makefile from xvidcore.library source code:

  1. CC = gcc -mcrt=newlib
  2. RM = delete
  3. CP = copy
  4.  
  5. # Change these as required
  6. OPTIMIZE = -O3
  7. DEBUG =
  8. CFLAGS = -Wall $(OPTIMIZE) $(DEBUG) -Iinclude
  9.  
  10. # Flags passed to gcc during linking
  11. LINK =
  12.  
  13. # Name of the "thing" to build
  14. TARGET = xvidcore.library
  15.  
  16. # Additional linker libraries
  17. LIBS = -lxvidcore -lpthread
  18.  
  19. # Version of the library to build
  20. VERSION = 52
  21.  
  22. # Source code files used in this project
  23. # Add any additional files to this line
  24.  
  25. SRCS = init.c
  26.  
  27. # -------------------------------------------------------------
  28. # Nothing should need changing below this line
  29.  
  30. OBJS = $(SRCS:.c=.o)
  31. # Rules for building
  32. $(TARGET): $(OBJS)
  33. $(CC) $(LINK) -nostartfiles -o $@ $^ $(LIBS)
  34. strip -R.comment $@
  35.  
  36. init.o: $(TARGET)_rev.h
  37.  
  38. .PHONY: clean
  39. clean:
  40. $(RM) $(TARGET) $(OBJS)
  41.  
  42. .PHONY: install
  43. install: $(TARGET)
  44. $(CP) $(TARGET) LIBS:
  45.  
  46. .PHONY: revision
  47. revision:
  48. bumprev $(VERSION) $(TARGET)

You don't need to specify -mcrt=newlib any more since newlib is the default C library now but it doesn't hurt to do so either. Pretty much the only thing to watch out for when building a library or device is to disable linking of startup code which is done by using the -nostartfiles option.

In this Makefile I also strip the library using the strip command but this is not really necessary (only makes the file a little smaller).

Belxjander
Belxjander's picture
Offline
Last seen: 8 years 3 months ago
Joined: 2011-02-25 11:53
Thank you salass00, this is

Thank you salass00, this is exactly the kind of material I have been looking for,
glad to know there isn't really any special sauce for the Makefile part.

Now I just have to get the project to build... and for that I will *need* the sam440flex I am buying :)
Half-paid already... just need to get the rest together.

Log in or register to post comments