1SubDir HAIKU_TOP src tools gensyscalls ; 2 3# preprocess the syscalls header 4 5rule PreprocessSyscalls 6{ 7 # PreprocessSyscalls <preprocessedHeader> : <header> : <parsable> ; 8 # 9 local parsable = $(3) ; 10 local parsableDefine ; 11 12 if $(parsable) { 13 parsableDefine = GEN_SYSCALL_INFOS_PROCESSING ; 14 } 15 16 Depends $(<) : $(>) ; 17 18 local headers = [ on $(1) return $(SEARCH_SOURCE) $(SUBDIRHDRS) $(HDRS) ] ; 19 local sysHeaders = 20 [ PrivateHeaders kernel ] 21 [ ArchHeaders $(TARGET_ARCH) ] 22 [ on $(1) return $(SUBDIRSYSHDRS) $(SYSHDRS) ] 23 $(HAIKU_HDRS) ; 24 25 HDRS on $(<) = $(headers) ; 26 SYSHDRS on $(<) = $(sysHeaders) ; 27 28 HDRRULE on $(>) = HdrRule ; 29 HDRSCAN on $(>) = $(HDRPATTERN) ; 30 HDRSEARCH on $(>) = $(headers) $(sysHeaders) $(STDHDRS) ; 31 HDRGRIST on $(>) = $(HDRGRIST) ; 32 33 DEFINES on $(<) += $(HAIKU_DEFINES) $(parsableDefine) ; 34 35 CCFLAGS on $(<) += $(HAIKU_CCFLAGS) $(SUBDIRCCFLAGS) $(OPTIM) ; 36 CCHDRS on $(<) = [ FIncludes $(headers) : $(HAIKU_LOCAL_INCLUDES_OPTION) ] 37 $(HAIKU_INCLUDES_SEPARATOR) 38 [ FSysIncludes $(sysHeaders) : $(HAIKU_SYSTEM_INCLUDES_OPTION) ] ; 39 CCDEFS on $(<) = [ on $(<) FDefines $(DEFINES) ] ; 40} 41 42actions PreprocessSyscalls 43{ 44 $(HAIKU_C++) -xc++ -E "$(2)" $(CCFLAGS) $(CCDEFS) $(CCHDRS) -o "$(1)" ; 45} 46 47local syscallsHeader = [ FGristFiles syscalls.h ] ; 48SEARCH on $(syscallsHeader) = [ FDirName $(HAIKU_TOP) headers private kernel ] ; 49 50# We generate two preprocessed headers. One for parsing by gensyscallinfos 51# (it contains #pragmas) and one for inclusion by the generated 52# gensyscalls_infos.cpp. 53local syscallsHeaderPPParsable = [ FGristFiles syscalls.h.pp.parsable ] ; 54local syscallsHeaderPP = [ FGristFiles syscalls.h.pp ] ; 55MakeLocateArch $(syscallsHeaderPPParsable) $(syscallsHeaderPP) ; 56 57PreprocessSyscalls $(syscallsHeaderPPParsable) : $(syscallsHeader) : true ; 58PreprocessSyscalls $(syscallsHeaderPP) : $(syscallsHeader) ; 59 60 61# build gensyscallinfos 62 63BuildPlatformMain gensyscallinfos 64 : gensyscallinfos.cpp 65 : $(HOST_LIBSTDC++) 66; 67 68 69# generate the syscall infos source file 70 71local syscallInfos = [ FGristFiles gensyscalls_infos.cpp ] ; 72MakeLocateArch $(syscallInfos) ; 73 74rule GenSyscallInfos { 75 Depends $(1) : gensyscallinfos $(2) ; 76 GenSyscallInfos1 $(1) : gensyscallinfos $(2) ; 77} 78 79actions GenSyscallInfos1 { 80 $(2[1]) $(2[2]) $(1) 81} 82 83GenSyscallInfos $(syscallInfos) : $(syscallsHeaderPPParsable) ; 84 85SubDirHdrs [ FDirName $(SUBDIR) arch $(TARGET_ARCH) ] ; 86 87 88# build gensyscalls 89 90BuildPlatformMain gensyscalls : gensyscalls.cpp $(syscallInfos) ; 91LinkAgainst gensyscalls : $(HOST_LIBSTDC++) ; 92 93# Explicitly tell jam that gensyscalls.cpp includes the generated header. 94Includes [ FGristFiles gensyscalls.cpp ] : $(syscallsHeaderPP) ; 95 96 97# generate the output files 98 99# place them where they are needed 100local dir = $(HAIKU_COMMON_DEBUG_OBJECT_DIR) ; 101MakeLocate <syscalls>syscalls.S.inc : [ FDirName $(dir) system libroot os ] ; 102MakeLocate <syscalls>syscall_dispatcher.h : [ FDirName $(dir) system kernel ] ; 103MakeLocate <syscalls>syscall_numbers.h : [ FDirName $(dir) system kernel ] ; 104MakeLocate <syscalls>syscall_table.h : [ FDirName $(dir) system kernel ] ; 105MakeLocate <syscalls>strace_syscalls.h : [ FDirName $(dir) bin strace ] ; 106 107rule GenSyscallsFile { 108 Depends $(1) : gensyscalls ; 109 GenSyscallsFile1 $(1) : gensyscalls ; 110} 111 112actions GenSyscallsFile1 { 113 $(2[1]) -c $(1) 114} 115 116rule GenSyscallsDispatcher { 117 Depends $(1) : gensyscalls ; 118 GenSyscallsDispatcher1 $(1) : gensyscalls ; 119} 120 121actions GenSyscallsDispatcher1 { 122 $(2[1]) -d $(1) 123} 124 125rule GenSyscallsNumbers { 126 Depends $(1) : gensyscalls ; 127 GenSyscallsNumbers1 $(1) : gensyscalls ; 128} 129 130actions GenSyscallsNumbers1 { 131 $(2[1]) -n $(1) 132} 133 134rule GenSyscallsTable { 135 Depends $(1) : gensyscalls ; 136 GenSyscallsTable1 $(1) : gensyscalls ; 137} 138 139actions GenSyscallsTable1 { 140 $(2[1]) -t $(1) 141} 142 143rule GenSyscallsSTrace { 144 Depends $(1) : gensyscalls ; 145 GenSyscallsSTrace1 $(1) : gensyscalls ; 146} 147 148actions GenSyscallsSTrace1 { 149 $(2[1]) -s $(1) 150} 151 152GenSyscallsFile <syscalls>syscalls.S.inc ; 153GenSyscallsDispatcher <syscalls>syscall_dispatcher.h ; 154GenSyscallsNumbers <syscalls>syscall_numbers.h ; 155GenSyscallsTable <syscalls>syscall_table.h ; 156GenSyscallsSTrace <syscalls>strace_syscalls.h ; 157