<commit_before>#################################################
#          IncludeOS SERVICE makefile           #
#################################################

# The name of your service
SERVICE = My_IncludeOS_Service

# Your service parts
FILES = service.cpp

# IncludeOS location
ifndef INCLUDEOS_INSTALL
	INCLUDEOS_INSTALL=$(HOME)/IncludeOS_install
endif

# Shorter name
INSTALL = $(INCLUDEOS_INSTALL)

# Compiler and linker options
###################################################
CAPABS_COMMON = -mstackrealign -msse3
WARNS  = -Wall -Wextra #-pedantic
DEBUG_OPTS = -ggdb3 -v

OPTIONS = $(WARNS) $(CAPABS)

# External Libraries
###################################################
LIBC_OBJ = $(INSTALL)/newlib/libc.a
LIBG_OBJ = $(INSTALL)/newlib/libg.a
LIBM_OBJ = $(INSTALL)/newlib/libm.a 

LIBGCC = $(INSTALL)/libgcc/libgcc.a
LIBCXX = $(INSTALL)/libcxx/libc++.a $(INSTALL)/libcxx/libc++abi.a


INC_NEWLIB=$(INSTALL)/newlib/include
INC_LIBCXX=$(INSTALL)/libcxx/include

CPP = clang++-3.6 -target i686-elf
ifndef LD_INC
	LD_INC = ld
endif

INCLUDES = -I$(INC_LIBCXX) -I$(INSTALL)/api/sys -I$(INC_NEWLIB) -I$(INSTALL)/api 

all: CAPABS  =  $(CAPABS_COMMON) -O2  
debug: CAPABS = $(CAPABS_COMMON) -O0
stripped: CAPABS = $(CAPABS_COMMON) -Oz

CPPOPTS = $(CAPABS) $(WARNS) -c -m32 -std=c++14 -fno-stack-protector $(INCLUDES) -D_LIBCPP_HAS_NO_THREADS=1 #-flto -fno-exceptions
LDOPTS = -nostdlib -melf_i386 -N --script=$(INSTALL)/linker.ld

# Objects
###################################################

CRTBEGIN_OBJ = $(INSTALL)/crt/crtbegin.o
CRTEND_OBJ = $(INSTALL)/crt/crtend.o
CRTI_OBJ = $(INSTALL)/crt/crti.o
CRTN_OBJ = $(INSTALL)/crt/crtn.o

# Full link list
OBJS  = $(FILES:.cpp=.o) .service_name.o
LIBS =  $(INSTALL)/os.a $(LIBCXX) $(INSTALL)/os.a $(LIBC_OBJ) $(LIBM_OBJ) $(LIBGCC)

OS_PRE = $(CRTBEGIN_OBJ) $(CRTI_OBJ)
OS_POST = $(CRTEND_OBJ) $(CRTN_OBJ)

DEPS = $(OBJS:.o=.d)

# Complete build
###################################################
# A complete build includes:
# - a "service", to be linked with OS-objects (OS included)

all: service

stripped: LDOPTS  += -S #strip all
stripped: CPPOPTS += -Oz
stripped: service


# The same, but with debugging symbols (OBS: Dramatically increases binary size)
debug: CCOPTS  += $(DEBUG_OPTS)
debug: CPPOPTS += $(DEBUG_OPTS)
debug: LDOPTS  += -M --verbose
debug: OBJS += $(LIBG_OBJ)
debug: service #Don't wanna call 'all', since it strips debug info

# Disk image as a section
###################################################
memdisk: $(INSTALL)/memdisk/memdisk.asm
	@echo "\n>> Assembling memdisk"
	nasm -f elf -o memdisk.o $<

# Service
###################################################
service.o: service.cpp
	@echo "\n>> Compiling the service"
	$(CPP) $(CPPOPTS) -o $@ $<

.service_name.o: $(INSTALL)/service_name.cpp
	$(CPP) $(CPPOPTS) -DSERVICE_NAME="\"$(SERVICE_NAME)\"" -o $@ $<

# Link the service with the os
service: $(OBJS) $(LIBS)
ifneq ($(DISK),)
	@echo "\n>> Creating memdisk"
	python $(INSTALL)/memdisk/memdisk.py --file $(INSTALL)/memdisk/memdisk.asm $(DISK)
	$(MAKE) memdisk
else
	# skip creating memdisk
	nasm -f elf -o memdisk.o $(INSTALL)/memdisk/empty.asm
endif
	@echo "\n>> Linking service with OS"
	$(LD_INC) $(LDOPTS) $(OS_PRE) $(OBJS) $(LIBS) $(OS_POST) memdisk.o -o $(SERVICE)
	@echo "\n>> Building image " $(SERVICE).img
	$(INSTALL)/vmbuild $(INSTALL)/bootloader $(SERVICE)

# Object files<commit_msg>build: Better memdisk image solution for makefile<commit_after>#################################################
#          IncludeOS SERVICE makefile           #
#################################################

# The name of your service
SERVICE = My_IncludeOS_Service

# Your service parts
FILES = service.cpp

# IncludeOS location
ifndef INCLUDEOS_INSTALL
	INCLUDEOS_INSTALL=$(HOME)/IncludeOS_install
endif

ifneq ($(DISK),)
IMAGES=memdisk.o
endif

# Shorter name
INSTALL = $(INCLUDEOS_INSTALL)

# Compiler and linker options
###################################################
CAPABS_COMMON = -mstackrealign -msse3
WARNS  = -Wall -Wextra #-pedantic
DEBUG_OPTS = -ggdb3 -v

OPTIONS = $(WARNS) $(CAPABS)

# External Libraries
###################################################
LIBC_OBJ = $(INSTALL)/newlib/libc.a
LIBG_OBJ = $(INSTALL)/newlib/libg.a
LIBM_OBJ = $(INSTALL)/newlib/libm.a 

LIBGCC = $(INSTALL)/libgcc/libgcc.a
LIBCXX = $(INSTALL)/libcxx/libc++.a $(INSTALL)/libcxx/libc++abi.a


INC_NEWLIB=$(INSTALL)/newlib/include
INC_LIBCXX=$(INSTALL)/libcxx/include

CPP = clang++-3.6 -target i686-elf
ifndef LD_INC
	LD_INC = ld
endif

INCLUDES = -I$(INC_LIBCXX) -I$(INSTALL)/api/sys -I$(INC_NEWLIB) -I$(INSTALL)/api 

all: CAPABS  =  $(CAPABS_COMMON) -O2  
debug: CAPABS = $(CAPABS_COMMON) -O0
stripped: CAPABS = $(CAPABS_COMMON) -Oz

CPPOPTS = $(CAPABS) $(WARNS) -c -m32 -std=c++14 -fno-stack-protector $(INCLUDES) -D_LIBCPP_HAS_NO_THREADS=1 #-flto -fno-exceptions
LDOPTS = -nostdlib -melf_i386 -N --script=$(INSTALL)/linker.ld

# Objects
###################################################

CRTBEGIN_OBJ = $(INSTALL)/crt/crtbegin.o
CRTEND_OBJ = $(INSTALL)/crt/crtend.o
CRTI_OBJ = $(INSTALL)/crt/crti.o
CRTN_OBJ = $(INSTALL)/crt/crtn.o

# Full link list
OBJS  = $(FILES:.cpp=.o) .service_name.o
LIBS =  $(INSTALL)/os.a $(LIBCXX) $(INSTALL)/os.a $(LIBC_OBJ) $(LIBM_OBJ) $(LIBGCC)

OS_PRE = $(CRTBEGIN_OBJ) $(CRTI_OBJ)
OS_POST = $(CRTEND_OBJ) $(CRTN_OBJ)

DEPS = $(OBJS:.o=.d)

# Complete build
###################################################
# A complete build includes:
# - a "service", to be linked with OS-objects (OS included)

all: service

stripped: LDOPTS  += -S #strip all
stripped: CPPOPTS += -Oz
stripped: service


# The same, but with debugging symbols (OBS: Dramatically increases binary size)
debug: CCOPTS  += $(DEBUG_OPTS)
debug: CPPOPTS += $(DEBUG_OPTS)
debug: LDOPTS  += -M --verbose
debug: OBJS += $(LIBG_OBJ)
debug: service #Don't wanna call 'all', since it strips debug info

# Disk image as a section
###################################################
memdisk.o: $(INSTALL)/memdisk/memdisk.asm
	@echo "\n>> Creating memdisk"
	python $(INSTALL)/memdisk/memdisk.py --file $< $(DISK)
	@echo "\n>> Assembling memdisk"
	nasm -f elf $< -o $@

# Service
###################################################
service.o: service.cpp
	@echo "\n>> Compiling the service"
	$(CPP) $(CPPOPTS) -o $@ $<

.service_name.o: $(INSTALL)/service_name.cpp
	$(CPP) $(CPPOPTS) -DSERVICE_NAME="\"$(SERVICE_NAME)\"" -o $@ $<

# Link the service with the os
service: $(OBJS) $(LIBS)
	# build memdisk when IMAGES is set
ifneq ($(IMAGES),)
	$(MAKE) memdisk.o
endif
	@echo "\n>> Linking service with OS"
	$(LD_INC) $(LDOPTS) $(OS_PRE) $(OBJS) $(LIBS) $(OS_POST) $(IMAGES) -o $(SERVICE)
	@echo "\n>> Building" $(SERVICE).img
	$(INSTALL)/vmbuild $(INSTALL)/bootloader $(SERVICE)

# Object files
{'fraction_non_alphanumeric': 0.26457597173144876, 'fraction_numerical': 0.005005889281507656, 'mean_word_length': 5.103324348607368, 'pattern_counts': {'":': 0, '<': 10, '<?xml version=': 0, '>': 23, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2082891', 'n_tokens_mistral': 2627, 'n_tokens_neox': 2393, 'n_words': 570}