For my projects, using regular makefiles (no autoconfig), I create a
basic template, and then modify them for each target OS. The results
looked like the following for the dynamic library. This approach isn’t
as generalizable as the autoconfig approach, but it may get you up and
running. Hope this helps,
John
#Makefile for linux using gcc
MAKEFILE = Makefile.unix
MKDP = makedepend
CC = g++
CFLAGS = -fPIC
LFLAGS = -shared
LIBS = -lGL -lGLU -lSDL -lSDL_image -lm
LIBDIR = /usr/lib
#Packages
SRCS = {Fill this in}
OBJS = $(SRCS:.cpp=.o)
MAIN = libXOR.so#
The following part of the makefile is generic; it can be used to
build any executable just by changing the definitions above and by
deleting dependencies appended to the file from ‘make depend’
all: $(MAIN)
cp -f $(MAIN) ./lib/$(MAIN)
install: $(SPECIAL)
cp -f ./lib/$(MAIN) $(LIBDIR)/$(MAIN)
$(MAIN): $(OBJS)
$(CC) $(LFLAGS) -o $(MAIN) $(OBJS) $(LIBS)
.cpp.o:
$(CC) $(CFLAGS) -o $@ -c $<
clean:
$(RM) $(OBJS) $(MAIN)
depend: $(SRCS)
$(MKDP) -f$(MAKEFILE) 2> /dev/null $(INCLUDES) $^
DO NOT DELETE THIS LINE – make depend needs it
-----For mingw, I changed the top portion to-----
#Makefile for windows using MinGW
MAKEFILE = Makefile.mingw
CFLAGS = -O3
CC = g++
LFLAGS = -shared
#Notice that libs dir does not specify the ending ''
LIBDIR = C:\Dev-Cpp\lib
LIBS = -L$(LIBDIR) -mwindows -lws2_32 -lmingw32 lib\SDL_image.dll
lib\libSDL.dll.a lib\libSDLmain.a -lopengl32 -lglu32 -lm
#Packages
SRCS = {Fill this in}
OBJS = $(SRCS:.cpp=.o)
MAIN = XOR.DLL
CP = COPY /Y
-----For OSX, I changed the top portion to-----
Makefile for the macintosh
MAKEFILE = Makefile.osx
Change the location of makedepend with this line, then comment out
the following definition.
#MKDP = /usr/X11R6/bin/makedepend
MKDP = makedepend
CC = g++
LFLAGS = -dynamiclib
LIBS = -L/sw/lib -framework OpenGL -framework SDL -framework SDL_mixer
-lSDL -framework SDL_image -lm
Notice that libdir does not specify the ending /
LIBDIR = /usr/local/lib
#Packages
SRCS = {Fill this in}
OBJS = $(SRCS:.cpp=.o)
MAIN = libXOR.so
.PHONY: FIRST depend clean
Since we are using an extra rule, we need to make sure that default
processing goes to the all target first.
FIRST: all
The install target will depend on SPECIAL, which means that
this target will acutally execute first.
Because we are just symlinking, that won’t cause any problems.
SPECIAL = libXOR.dylib
$(SPECIAL):
ln -fs $(LIBDIR)/$(MAIN) $(LIBDIR)/$(SPECIAL)