[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: makefile for digitalmars C
- From: John J Foerch <jjfoerch@...>
- Date: Tue, 13 May 2008 20:51:59 -0400
Hello,
I have been experimenting with lua on a win98 machine with digitalmars
C. Attached is the makefile I came up with for the src directory. I
would like to contribute this or the equivalent better to the project,
along with my ability to test and troubleshoot to streamline the build
process under digitalmars.
Although it should be possible to write a unified makefile that works
with both gnu make and digitalmars make, I fear there would be a
sacrifice in readability to go that way. What I did instead is to write
this separate makefile, with clear comments explaining the ways it
differs from the master makefile. With this approach, it should be a
simple matter for the rare digitalmars user to make needed changes when
the normal makefile changes.
Comments? Ideas?
Thank you,
John Foerch
# makefile for building Lua with Digitalmars C Compiler, modified from
# original Lua makefile by John Foerch.
#
# this makefile goes in src. to do a manual install after build, copy
# *.exe into a directory in your path, *.lib into your dm lib dir, and
# *.h into your dm include dir--roughly speaking.
#
# Differences from normal Makefile:
#
# PLAT = ansi
# define MAKE
# set CC, AR, RANLIB appropriate for digitalmars.
# remove "-lm" from LIBS
# rename *.o to *.obj. dmc assumes object files are .obj in link stage.
# rename *.a to *.lib
# give executables .exe suffix
# no space between -o and its arg in calls to $(CC)
# write out commands for all the *.o (*.obj) targets.
#
# known to work with versions:
#
# 5.1.3
##
# makefile for building Lua
# see ../INSTALL for installation instructions
# see ../Makefile and luaconf.h for further customization
# == CHANGE THE SETTINGS BELOW TO SUIT YOUR ENVIRONMENT =======================
# Your platform. See PLATS for possible values.
PLAT= ansi
MAKE= make -f Makefile.dm
CC= dmc
CFLAGS= $(MYCFLAGS)
AR= lib -c
RANLIB= lib -c
RM= rm -f
LIBS= $(MYLIBS)
MYCFLAGS=
MYLDFLAGS=
MYLIBS=
# == END OF USER SETTINGS. NO NEED TO CHANGE ANYTHING BELOW THIS LINE =========
PLATS= aix ansi bsd freebsd generic linux macosx mingw posix solaris
LUA_A= liblua.lib
CORE_O= lapi.obj lcode.obj ldebug.obj ldo.obj ldump.obj lfunc.obj lgc.obj llex.obj lmem.obj \
lobject.obj lopcodes.obj lparser.obj lstate.obj lstring.obj ltable.obj ltm.obj \
lundump.obj lvm.obj lzio.obj
LIB_O= lauxlib.obj lbaselib.obj ldblib.obj liolib.obj lmathlib.obj loslib.obj ltablib.obj \
lstrlib.obj loadlib.obj linit.obj
LUA_T= lua.exe
LUA_O= lua.obj
LUAC_T= luac.exe
LUAC_O= luac.obj print.obj
ALL_O= $(CORE_O) $(LIB_O) $(LUA_O) $(LUAC_O)
ALL_T= $(LUA_A) $(LUA_T) $(LUAC_T)
ALL_A= $(LUA_A)
default: $(PLAT)
all: $(ALL_T)
o: $(ALL_O)
a: $(ALL_A)
$(LUA_A): $(CORE_O) $(LIB_O)
$(AR) $@ $?
$(RANLIB) $@
$(LUA_T): $(LUA_O) $(LUA_A)
$(CC) -o$@ $(MYLDFLAGS) $(LUA_O) $(LUA_A) $(LIBS)
$(LUAC_T): $(LUAC_O) $(LUA_A)
$(CC) -o$@ $(MYLDFLAGS) $(LUAC_O) $(LUA_A) $(LIBS)
clean:
$(RM) $(ALL_T) $(ALL_O)
depend:
@$(CC) $(CFLAGS) -MM l*.c print.c
echo:
@echo "PLAT = $(PLAT)"
@echo "CC = $(CC)"
@echo "CFLAGS = $(CFLAGS)"
@echo "AR = $(AR)"
@echo "RANLIB = $(RANLIB)"
@echo "RM = $(RM)"
@echo "MYCFLAGS = $(MYCFLAGS)"
@echo "MYLDFLAGS = $(MYLDFLAGS)"
@echo "MYLIBS = $(MYLIBS)"
# convenience targets for popular platforms
none:
@echo "Please choose a platform:"
@echo " $(PLATS)"
aix:
$(MAKE) all CC="xlc" CFLAGS="-O2 -DLUA_USE_POSIX -DLUA_USE_DLOPEN" MYLIBS="-ldl" MYLDFLAGS="-brtl -bexpall"
ansi:
$(MAKE) all MYCFLAGS=-DLUA_ANSI
bsd:
$(MAKE) all MYCFLAGS="-DLUA_USE_POSIX -DLUA_USE_DLOPEN" MYLIBS="-Wl,-E"
freebsd:
$(MAKE) all MYCFLAGS="-DLUA_USE_LINUX" MYLIBS="-Wl,-E -lreadline"
generic:
$(MAKE) all MYCFLAGS=
linux:
$(MAKE) all MYCFLAGS=-DLUA_USE_LINUX MYLIBS="-Wl,-E -ldl -lreadline -lhistory -lncurses"
macosx:
$(MAKE) all MYCFLAGS=-DLUA_USE_LINUX MYLIBS="-lreadline"
# use this on Mac OS X 10.3-
# $(MAKE) all MYCFLAGS=-DLUA_USE_MACOSX
mingw:
$(MAKE) "LUA_A=lua51.dll" "LUA_T=lua.exe" \
"AR=$(CC) -shared -o" "RANLIB=strip --strip-unneeded" \
"MYCFLAGS=-DLUA_BUILD_AS_DLL" "MYLIBS=" "MYLDFLAGS=-s" lua.exe
$(MAKE) "LUAC_T=luac.exe" luac.exe
posix:
$(MAKE) all MYCFLAGS=-DLUA_USE_POSIX
solaris:
$(MAKE) all MYCFLAGS="-DLUA_USE_POSIX -DLUA_USE_DLOPEN" MYLIBS="-ldl"
# list targets that do not create files (but not all makes understand .PHONY)
.PHONY: all $(PLATS) default o a clean depend echo none
# DO NOT DELETE
lapi.obj: lapi.c lua.h luaconf.h lapi.h lobject.h llimits.h ldebug.h \
lstate.h ltm.h lzio.h lmem.h ldo.h lfunc.h lgc.h lstring.h ltable.h \
lundump.h lvm.h
$(CC) $(CFLAGS) -o$@ -c lapi.c
lauxlib.obj: lauxlib.c lua.h luaconf.h lauxlib.h
$(CC) $(CFLAGS) -o$@ -c lauxlib.c
lbaselib.obj: lbaselib.c lua.h luaconf.h lauxlib.h lualib.h
$(CC) $(CFLAGS) -o$@ -c lbaselib.c
lcode.obj: lcode.c lua.h luaconf.h lcode.h llex.h lobject.h llimits.h \
lzio.h lmem.h lopcodes.h lparser.h ldebug.h lstate.h ltm.h ldo.h lgc.h \
ltable.h
$(CC) $(CFLAGS) -o$@ -c lcode.c
ldblib.obj: ldblib.c lua.h luaconf.h lauxlib.h lualib.h
$(CC) $(CFLAGS) -o$@ -c ldblib.c
ldebug.obj: ldebug.c lua.h luaconf.h lapi.h lobject.h llimits.h lcode.h \
llex.h lzio.h lmem.h lopcodes.h lparser.h ldebug.h lstate.h ltm.h ldo.h \
lfunc.h lstring.h lgc.h ltable.h lvm.h
$(CC) $(CFLAGS) -o$@ -c ldebug.c
ldo.obj: ldo.c lua.h luaconf.h ldebug.h lstate.h lobject.h llimits.h ltm.h \
lzio.h lmem.h ldo.h lfunc.h lgc.h lopcodes.h lparser.h lstring.h \
ltable.h lundump.h lvm.h
$(CC) $(CFLAGS) -o$@ -c ldo.c
ldump.obj: ldump.c lua.h luaconf.h lobject.h llimits.h lstate.h ltm.h \
lzio.h lmem.h lundump.h
$(CC) $(CFLAGS) -o$@ -c ldump.c
lfunc.obj: lfunc.c lua.h luaconf.h lfunc.h lobject.h llimits.h lgc.h lmem.h \
lstate.h ltm.h lzio.h
$(CC) $(CFLAGS) -o$@ -c lfunc.c
lgc.obj: lgc.c lua.h luaconf.h ldebug.h lstate.h lobject.h llimits.h ltm.h \
lzio.h lmem.h ldo.h lfunc.h lgc.h lstring.h ltable.h
$(CC) $(CFLAGS) -o$@ -c lgc.c
linit.obj: linit.c lua.h luaconf.h lualib.h lauxlib.h
$(CC) $(CFLAGS) -o$@ -c linit.c
liolib.obj: liolib.c lua.h luaconf.h lauxlib.h lualib.h
$(CC) $(CFLAGS) -o$@ -c liolib.c
llex.obj: llex.c lua.h luaconf.h ldo.h lobject.h llimits.h lstate.h ltm.h \
lzio.h lmem.h llex.h lparser.h lstring.h lgc.h ltable.h
$(CC) $(CFLAGS) -o$@ -c llex.c
lmathlib.obj: lmathlib.c lua.h luaconf.h lauxlib.h lualib.h
$(CC) $(CFLAGS) -o$@ -c lmathlib.c
lmem.obj: lmem.c lua.h luaconf.h ldebug.h lstate.h lobject.h llimits.h \
ltm.h lzio.h lmem.h ldo.h
$(CC) $(CFLAGS) -o$@ -c lmem.c
loadlib.obj: loadlib.c lua.h luaconf.h lauxlib.h lualib.h
$(CC) $(CFLAGS) -o$@ -c loadlib.c
lobject.obj: lobject.c lua.h luaconf.h ldo.h lobject.h llimits.h lstate.h \
ltm.h lzio.h lmem.h lstring.h lgc.h lvm.h
$(CC) $(CFLAGS) -o$@ -c lobject.c
lopcodes.obj: lopcodes.c lopcodes.h llimits.h lua.h luaconf.h
$(CC) $(CFLAGS) -o$@ -c lopcodes.c
loslib.obj: loslib.c lua.h luaconf.h lauxlib.h lualib.h
$(CC) $(CFLAGS) -o$@ -c loslib.c
lparser.obj: lparser.c lua.h luaconf.h lcode.h llex.h lobject.h llimits.h \
lzio.h lmem.h lopcodes.h lparser.h ldebug.h lstate.h ltm.h ldo.h \
lfunc.h lstring.h lgc.h ltable.h
$(CC) $(CFLAGS) -o$@ -c lparser.c
lstate.obj: lstate.c lua.h luaconf.h ldebug.h lstate.h lobject.h llimits.h \
ltm.h lzio.h lmem.h ldo.h lfunc.h lgc.h llex.h lstring.h ltable.h
$(CC) $(CFLAGS) -o$@ -c lstate.c
lstring.obj: lstring.c lua.h luaconf.h lmem.h llimits.h lobject.h lstate.h \
ltm.h lzio.h lstring.h lgc.h
$(CC) $(CFLAGS) -o$@ -c lstring.c
lstrlib.obj: lstrlib.c lua.h luaconf.h lauxlib.h lualib.h
$(CC) $(CFLAGS) -o$@ -c lstrlib.c
ltable.obj: ltable.c lua.h luaconf.h ldebug.h lstate.h lobject.h llimits.h \
ltm.h lzio.h lmem.h ldo.h lgc.h ltable.h
$(CC) $(CFLAGS) -o$@ -c ltable.c
ltablib.obj: ltablib.c lua.h luaconf.h lauxlib.h lualib.h
$(CC) $(CFLAGS) -o$@ -c ltablib.c
ltm.obj: ltm.c lua.h luaconf.h lobject.h llimits.h lstate.h ltm.h lzio.h \
lmem.h lstring.h lgc.h ltable.h
$(CC) $(CFLAGS) -o$@ -c ltm.c
lua.obj: lua.c lua.h luaconf.h lauxlib.h lualib.h
$(CC) $(CFLAGS) -o$@ -c lua.c
luac.obj: luac.c lua.h luaconf.h lauxlib.h ldo.h lobject.h llimits.h \
lstate.h ltm.h lzio.h lmem.h lfunc.h lopcodes.h lstring.h lgc.h \
lundump.h
$(CC) $(CFLAGS) -o$@ -c luac.c
lundump.obj: lundump.c lua.h luaconf.h ldebug.h lstate.h lobject.h \
llimits.h ltm.h lzio.h lmem.h ldo.h lfunc.h lstring.h lgc.h lundump.h
$(CC) $(CFLAGS) -o$@ -c lundump.c
lvm.obj: lvm.c lua.h luaconf.h ldebug.h lstate.h lobject.h llimits.h ltm.h \
lzio.h lmem.h ldo.h lfunc.h lgc.h lopcodes.h lstring.h ltable.h lvm.h
$(CC) $(CFLAGS) -o$@ -c lvm.c
lzio.obj: lzio.c lua.h luaconf.h llimits.h lmem.h lstate.h lobject.h ltm.h \
lzio.h
$(CC) $(CFLAGS) -o$@ -c lzio.c
print.obj: print.c ldebug.h lstate.h lua.h luaconf.h lobject.h llimits.h \
ltm.h lzio.h lmem.h lopcodes.h lundump.h
$(CC) $(CFLAGS) -o$@ -c print.c
# (end of Makefile)