diff --git a/app/Makefile b/app/Makefile deleted file mode 100755 index b475445025fc44032c5d84604381a0b070b197c5..0000000000000000000000000000000000000000 --- a/app/Makefile +++ /dev/null @@ -1,83 +0,0 @@ -# Copyright (c) 2020 Huawei Device Co., Ltd. -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -BASE_DIR := $(shell if [ "$$PWD" != "" ]; then echo $$PWD; else pwd; fi) - -BUILD_SUBDIRS = src - -MAKEFILE_PATH := $(dir $(abspath $(lastword $(MAKEFILE_LIST)))) -LITEOSTOPDIR = ${MAKEFILE_PATH}/../../../../kernel/liteos_a -CROSS_COMPILE = arm-linux-ohoseabi- -LITEOS_COMPILER_PATH := $(shell $(LITEOSTOPDIR)/tools/build/mk/get_compiler_path.sh $(CROSS_COMPILE) $(LITEOSTOPDIR)) -STRIP = ${LITEOS_COMPILER_PATH}/bin/$(CROSS_COMPILE)strip --strip-unneeded - -APP_DIR = $(BASE_DIR) - -FSIMG_SUBDIR = bin -FSIMG_DIR = $(APP_DIR)/$(FSIMG_SUBDIR) -APP_IMG = $(APP_DIR)/app.img - -LIBCIMG_SUBDIR = lib -LIBCIMG_DIR = $(APP_DIR)/$(LIBCIMG_SUBDIR) -LIBCFS_IMG = $(APP_DIR)/libc.img - -# Hide -Q = @ - -define DIR_template -$(1)_$(2): - $(Q) $(MAKE) -C $(1) $(3) APP_DIR="$(APP_DIR)" FSIMG_DIR="$(FSIMG_DIR)" Q="$(Q)" LITEOS_COMPILER_PATH="$(LITEOS_COMPILER_PATH)" CROSS_COMPILE="$(CROSS_COMPILE)" -endef - -all: $(APP_IMG) $(LIBCFS_IMG) -.PHONY: all build clean install populate - -$(foreach DIR, $(BUILD_SUBDIRS), $(eval $(call DIR_template,$(DIR),build, all))) -$(foreach DIR, $(BUILD_SUBDIRS), $(eval $(call DIR_template,$(DIR),clean,clean))) -$(foreach DIR, $(BUILD_SUBDIRS), $(eval $(call DIR_template,$(DIR),install,install))) - -# Build program(s) in each sud-directory - -build: $(foreach DIR, $(BUILD_SUBDIRS), $(DIR)_build) - -# Install each program in the file system image directory - -install: $(foreach DIR, $(BUILD_SUBDIRS), $(DIR)_install) - $(Q) $(STRIP) $(wildcard $(FSIMG_SUBDIR)/*) - $(Q) $(STRIP) $(wildcard $(LIBCIMG_SUBDIR)/*) - -# Create the file system image directory - -$(FSIMG_DIR): - $(Q) mkdir -p $(FSIMG_DIR) - -# Populate the file system image directory - -populate: $(FSIMG_DIR) build install - -# Create the img file from the populated fs directory - -$(APP_IMG): populate - -# Create the libc.img file - -$(LIBCFS_IMG): - $(Q) mkdir -p $(LIBCIMG_DIR) - -# Clean each subdirectory - -clean: $(foreach DIR, $(BUILD_SUBDIRS), $(DIR)_clean) - $(Q) rm -f $(DIRLIST_HDR) $(APP_IMG) $(SYMTAB_SRC) $(LIBCFS_IMG) - $(Q) rm -rf $(FSIMG_DIR) $(LIBCIMG_DIR) - - diff --git a/app/src/Makefile b/app/src/Makefile deleted file mode 100755 index be590497ec59faebceca1ef037466f8eb06a1097..0000000000000000000000000000000000000000 --- a/app/src/Makefile +++ /dev/null @@ -1,83 +0,0 @@ -# Copyright (c) 2020 Huawei Device Co., Ltd. -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -# Choose the type of compiling: -# "STATIC_COMPILE = y" means compiling in a static way, -# "STATIC_COMPILE = n" means compiling in a dynamic way. -STATIC_COMPILE = n - -BIN = helloworld -BIN_ASM = $(BIN).asm -OBJEXT = .o - -CC = ${LITEOS_COMPILER_PATH}/bin/$(CROSS_COMPILE)gcc -CPP = ${LITEOS_COMPILER_PATH}/bin/$(CROSS_COMPILE)g++ -LD = ${LITEOS_COMPILER_PATH}/bin/$(CROSS_COMPILE)ld -OBJDUMP = ${LITEOS_COMPILER_PATH}/bin/$(CROSS_COMPILE)objdump - -COMMON_INCLUDE = -I $(APP_DIR)/include/ -COMMON_FLAGS = -fPIE -D_XOPEN_SOURCE=700 - -CFLAGS += -fno-omit-frame-pointer -std=c99 $(COMMON_INCLUDE) $(COMMON_FLAGS) -CXXFLAGS += $(COMMON_INCLUDE) $(COMMON_FLAGS) - -ifeq ($(STATIC_COMPILE), y) - LDFLAGS = --static -else - LDFLAGS = -pie -endif - -CCSRCS := $(wildcard *.c) -CCOBJS = $(CCSRCS:.c=$(OBJEXT)) -CXXSRCS := $(wildcard *.cpp) -CXXOBJS = $(CXXSRCS:.cpp=$(OBJEXT)) - -MUSL = musl/lib/libc.so - -all: $(MUSL) $(BIN) $(BIN_ASM) - -$(CCOBJS): %$(OBJEXT): %.c - @echo "CC: $<" - $(Q) $(CC) -c $(CFLAGS) $< -o $@ - -$(CXXOBJS): %$(OBJEXT): %.cpp - @echo "CPP: $<" - $(Q) $(CPP) -c $(CXXFLAGS) $< -o $@ - -$(BIN_ASM): $(BIN) - $(Q) rm -rf $(CCOBJS) $(CXXOBJS) - $(Q) $(OBJDUMP) -d $(BIN) > $(BIN_ASM) - -$(MUSL): - $(Q) rm -rf musl/ - $(Q) ./build_musl.sh &> build_musl.log - -$(BIN): $(MUSL) $(CCOBJS) $(CXXOBJS) -ifeq ($(STATIC_COMPILE), y) - @echo "LD: $^" - $(Q) $(CC) $(LDFLAGS) -o $@ $^ -else - @echo "LD: $^" - $(Q)mkdir -p $(APP_DIR)/lib/ - $(Q)cp -f $(APP_DIR)/src/musl/lib/libc.so $(APP_DIR)/lib/libc.so - $(Q)$(CC) $(LDFLAGS) -o $@ $(CCOBJS) $(CXXOBJS) -endif - -clean: - $(Q) rm -rf $(CCOBJS) $(CXXOBJS) $(BIN) $(BIN_ASM) - $(Q) rm -rf musl/ - $(Q) rm -rf build_musl.log - -install: - $(Q) mkdir -p $(FSIMG_DIR) - $(Q) install $(BIN) $(FSIMG_DIR)/$(BIN) diff --git a/app/src/build_musl.sh b/app/src/build_musl.sh deleted file mode 100755 index 93d7f499d252a1df575dec781b0d1c6b6882c094..0000000000000000000000000000000000000000 --- a/app/src/build_musl.sh +++ /dev/null @@ -1,43 +0,0 @@ -#!/bin/bash - -# Copyright (c) 2020 Huawei Device Co., Ltd. -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -set -e - -readonly MUSL_DIR="$PWD/musl" -readonly MUSL_SOURCE="$PWD/../../../../../third_party/musl/*" -export SYSROOT="$PWD/../../../../../prebuilts/gcc/linux-x86/arm/arm-linux-ohoseabi-gcc/target" -readonly LITEOSTOPDIR="$PWD/../../../../../kernel/liteos_a" - -BUILD=`gcc -dumpmachine` -HOST=`gcc -dumpmachine` -TARGET=arm-linux-ohoseabi -CROSS_COMPILER=arm-linux-ohoseabi- -CFLAGS_FOR_TARGET="-O2 -Wall -fstack-protector-strong -D_FORTIFY_SOURCE=2 -Wl,-z,relro,-z,now,-z,noexecstack -Wtrampolines" - -PARALLEL=`grep ^processor /proc/cpuinfo|wc -l` -LITEOS_COMPILER_PATH=`${LITEOSTOPDIR}/tools/build/mk/get_compiler_path.sh ${CROSS_COMPILER} ${LITEOSTOPDIR}` - -export PATH="${LITEOS_COMPILER_PATH}/bin:$PATH" - -#prepare to build musl -mkdir -p $MUSL_DIR -cp -r $MUSL_SOURCE $MUSL_DIR - -#build musl -pushd $MUSL_DIR -CC="${LITEOS_COMPILER_PATH}/bin/${CROSS_COMPILER}gcc $CFLAGS_FOR_TARGET" ./configure --with-headers=$SYSROOT/usr/include --build=$BUILD --host=$TARGET -make -j $PARALLEL CROSS=$CROSS_COMPILER -popd -