Changeset 123 for trunk/src/emx/Makefile


Ignore:
Timestamp:
May 12, 2003, 12:48:43 PM (22 years ago)
Author:
zap
Message:

Started the work for re-designing the EMX C runtime library to not require
EMX.DLL. The new design is projected to be as follows:

  • all emx syscalls are replaced with the routines from the old sys.lib library which is now compilable in both a.out and OMF formats.
  • the sys.a library should be made replaceable and selectable by some gcc switch (e.g. -msyslib=emx would link with emx.a instead of sys.a which would give almost full backward compatibility with emx).
  • All C functions names were renamed to not contain the starting underscore (e.g. fopen and not _fopen). The underscored aliases will be added later with the c_alias library (which will be generated automatically from all public symbols of libc; any exported symbol that do not start with an underscore will be given an underscored alias unless such a symbol is already defined).

Also a lot of updates to the building system. It is now much faster (thanks
to Knut's suggestion of using ash's builtin echo).
Also re-wrote thunk1.asm and thunk2.asm to GAS format; this removes the need
for MASM and makes it possible to use 16-bit functions in a.out programs
without the need for EMX.DLL.
Also made a lot of small changes I don't remember now.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/emx/Makefile

    • Property cvs2svn:cvs-rev changed from 1.2 to 1.3
    r122 r123  
    2323OUT = out/
    2424# Base installation directory
    25 INS = out/install/
     25INS = out/$(MODE)/install/
    2626# CPU type (pretend we are portable ;-)
    2727CPU = 386
     28# The object file format to use for tools (emxomf, ld and friends)
     29TOOLFMT.dbg = aout
     30TOOLFMT.opt = omf
     31TOOLFMT = $(TOOLFMT.$(MODE))
    2832
    2933# Use ash.exe which is quite fast (comparable to cmd.exe) but has more features
     
    4448CC = gcc -c
    4549# The C compiler flags
    46 CFLAGS = -Wall -Iinclude -Isrc/include $(CFLAGS.$(MODE)) $(CFLAGS.KIND)
     50CFLAGS.INC = -Iinclude -Isrc/include
     51CFLAGS = -Wall -mstack-arg-probe -Zmt $(CFLAGS.INC) $(CFLAGS.$(MODE)) $(CFLAGS.KIND)
    4752# The additional C compiler flags for different build modes
    4853CFLAGS.opt = -s -O3 -fomit-frame-pointer
     
    5055CFLAGS.aout =
    5156CFLAGS.omf = -Zomf
    52 CFLAGS.st =
    53 CFLAGS.mt = -Zmt
    5457CFLAGS.prof = -pg
    5558# The object files are put in subdirectory objectformat-targetkind,
     
    6366LD = gcc
    6467# Linker flags
    65 LDFLAGS = $(LDFLAGS.$(MODE)) $(LDFLAGS.KIND)
     68LDFLAGS = -Zmt $(LDFLAGS.$(MODE)) $(LDFLAGS.KIND)
    6669# Linker flags for different build modes
    6770LDFLAGS.opt = -s
     
    6972LDFLAGS.aout =
    7073LDFLAGS.omf = -Zomf -Zsys -Zsmall-conv -Zlinker /PM:VIO
    71 LDFLAGS.st =
    72 LDFLAGS.mt = -Zmt
    73 LDFLAGS.stp = -pg
    74 LDFLAGS.mtp = -pg -Zmt
     74LDFLAGS.prof = -pg
    7575# Linker flags for different kinds of target
    7676LDFLAGS.KIND = $(foreach x,$(subst -, ,$(firstword $(subst /, ,$(subst $.,,$@)))),$(LDFLAGS.$x))
     
    8888ARFLAGS = crs
    8989DO.LIBRARY = $(AR) $(ARFLAGS) $@ $(^O)
     90
     91# How to create dependencies
     92MAKEDEP = makedep
     93MAKEDEPFLAGS = $(CFLAGS.INC)
     94DO.DEPS = $(MAKEDEP) $(MAKEDEPFLAGS) \
     95  -I$(subst $(SPACE), -I,$(sort $(dir $^))) -p$(@D)/ -c -S -f$@ $^
     96
     97# How to convert an a.out file to the OMF format
     98DO.AOUT2OMF = emxomf $(strip $1 -o) $@ $<
    9099
    91100# How to filter just the object files from $^
     
    109118SEP := ==========================================================================
    110119
    111 # How to remove a file
     120# How to remove one or more files without questions
    112121RM = rm -f $1
     122# How to remove one or more directories without questions
     123RMDIR = rm -rf $1
     124# How to copy several files to a directory
     125CP = cp $1 $2
    113126# Miscelaneous tools
    114127MKDIR = mkdir.exe -p $1
     
    117130ECHOIZE = $(subst $$,\$$,$1$(strip $(subst $(SPACE)$(COMMA),$(COMMA),$(foreach x,2 3 4 5 6 7 8 9,$(if $($x),$(COMMA) $($x))))))
    118131# How to output a text string (with appended newline)
    119 # bird: skip the .exe and ash will use internal echo implementation which is way faster
    120 #ECHO = echo.exe "$(call ECHOIZE,$1,$2,$3,$4,$5,$6,$7,$8,$9)"
    121132ECHO = echo "$(call ECHOIZE,$1,$2,$3,$4,$5,$6,$7,$8,$9)"
    122133# Same but append the text to a file (given with first argument)
    123 # bird: skip the .exe and ash will use internal echo implementation which is way faster
    124 #FECHO = echo.exe "$(call ECHOIZE,$2,$3,$4,$5,$6,$7,$8,$9)" >> "$1"
    125134FECHO = echo "$(call ECHOIZE,$2,$3,$4,$5,$6,$7,$8,$9)" >> "$1"
    126135# How to replace the source file extension with a .o extension
     
    145154# Build rules (_@_ replaced by name of generated makefile)
    146155RULES :=
    147 
    148 .PHONY: default help all clean install
     156# The list of dependency files
     157TARGDEPEND :=
     158
     159.PHONY: default help all clean install cleandep cleandepend dep depend depdone
    149160.SUFFIXES:
    150 .SUFFIXES: .c .cpp .asm .s .o .exe .dll .a .lib
     161.SUFFIXES: .c .cpp .asm .s .o .exe .dll .a .lib .obj
    151162
    152163# Default target
     
    172183        @$(call ECHO,    clean - remove all generated files (remove all built files))
    173184        @$(call ECHO,    install - generate a installation tree in $(INS))
     185        @$(call ECHO,    dep - generate dependency files for all changed targets)
     186        @$(call ECHO,    cleandep - remove all dependency file)
    174187        @$(call ECHO,$(SEP))
    175188        @$(call ECHO,There are a number of variables than can be set in the make)
     
    181194        @$(call ECHO,$(SEP))
    182195
    183 all: $(MODULES)
     196all: $(TARGDIRS) $(MODULES)
    184197
    185198clean:
    186         rm -rf $(OUT)
    187 
    188 install: $(INSDIRS)
     199        $(call RMDIR,$(OUT))
     200
     201cleandep cleandepend:
     202        $(call RM,$(TARGDEPEND))
     203
     204dep depend:
     205        @$(MAKE) --no-print-directory BUILD_DEPS=1 depdone
     206
     207depdone:
     208        @$(call ECHO,Dependency files succesfully updated)
     209
     210install: all $(INSDIRS)
    189211        $(DO.INSTALL)
    190212
    191 $(OUT) $. $(INSDIRS) $(TARGDIRS):
     213$. $(INSDIRS) $(TARGDIRS):
    192214        $(call MKDIR,$@)
    193215
    194 # bird: add rule for generating the rules.
    195 rules: rules-rm $(OUT)genrules.smak
    196 rules-rm:
    197         @$(call RM,$(OUT)genrules.smak)
    198        
    199 #$(OUT)genrules.smak: $(OUT) Makefile $(SUBMAK)
    200 # bird: depeding on $(OUT) make it unstable.
    201 $(OUT)genrules.smak: Makefile $(SUBMAK)
    202         $(call MKDIR,$(@D))
    203         @$(call ECHO,Please wait, rebuilding make rules $@ ...)
     216$(OUT)genrules.smak: $(SUBMAK) # Makefile $(wildcard *.smak)
     217        @$(call MKDIR,$(OUT))
     218        @$(call ECHO,Please wait, rebuilding make rules ...)
    204219        @$(call RM,$@)
    205220        @$(call FECHO,$@,# Autogenerated file -- DO NOT EDIT!)
    206221        @$(subst _@,$@,$(RULES))
    207222
     223# The general a.out -> OMF conversion rule for object files
     224$.omf/%.obj: $.aout/%.o
     225        $(call DO.AOUT2OMF)
     226
     227# The general a.out -> OMF conversion rule for libraries
     228$.omf%.lib: $.aout%.a
     229        $(call DO.AOUT2OMF)
     230
    208231-include $(OUT)genrules.smak
    209 
Note: See TracChangeset for help on using the changeset viewer.