Browse Source
Now uses a modified MCPPBS. Add --host=riscv to configure path. Front-end server now just searches PATH for riscv-pk, so just install the pk to somewhere in your path.cs250
30 changed files with 9872 additions and 16 deletions
@ -0,0 +1,34 @@ |
|||
========================================================================== |
|||
Copyright License |
|||
========================================================================== |
|||
|
|||
Copyright (c) 2008, Christopher Batten |
|||
All rights reserved. |
|||
|
|||
Redistribution and use in source and binary forms, with or without |
|||
modification, are permitted provided that the following conditions are |
|||
met: |
|||
|
|||
* Redistributions of source code must retain the above copyright |
|||
notice, this list of conditions, and the following disclaimer. |
|||
|
|||
* Redistributions in binary form must reproduce the above copyright |
|||
notice, this list of conditions, and the following disclaimer in the |
|||
documentation and/or other materials provided with the distribution. |
|||
|
|||
* Neither the name of the Massachusetts Institute of Technology nor the |
|||
names of its contributors may be used to endorse or promote products |
|||
derived from this software without specific prior written permission. |
|||
|
|||
THIS SOFTWARE IS PROVIDED BY Christopher Batten ''AS IS'' AND ANY |
|||
EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
|||
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR |
|||
PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL Christopher Batten BE LIABLE |
|||
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR |
|||
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF |
|||
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS |
|||
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN |
|||
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
|||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF |
|||
THE POSSIBILITY OF SUCH DAMAGE. |
|||
|
|||
@ -0,0 +1,461 @@ |
|||
#=========================================================================
|
|||
# Toplevel Makefile for the Modular C++ Build System
|
|||
#=========================================================================
|
|||
# Please read the documenation in 'mcppbs-doc.txt' for more details on
|
|||
# how the Modular C++ Build System works. For most projects, a developer
|
|||
# will not need to make any changes to this makefile. The key targets
|
|||
# are as follows:
|
|||
#
|
|||
# - default : build all libraries and programs
|
|||
# - check : build and run all unit tests
|
|||
# - install : install headers, project library, and some programs
|
|||
# - clean : remove all generated content (except autoconf files)
|
|||
# - dist : make a source tarball
|
|||
# - distcheck : make a source tarball, untar it, check it, clean it
|
|||
# - distclean : remove everything
|
|||
#
|
|||
|
|||
#-------------------------------------------------------------------------
|
|||
# Basic setup
|
|||
#-------------------------------------------------------------------------
|
|||
|
|||
# Remove all default implicit rules since they can cause subtle bugs
|
|||
# and they just make things run slower
|
|||
.SUFFIXES: |
|||
% : %,v |
|||
% : RCS/%,v |
|||
% : RCS/% |
|||
% : s.% |
|||
% : SCCS/s.% |
|||
|
|||
# Default is to build the prereqs of the all target (defined at bottom)
|
|||
default : all |
|||
.PHONY : default |
|||
|
|||
project_name := @PACKAGE_TARNAME@ |
|||
src_dir := @srcdir@ |
|||
scripts_dir := $(src_dir)/scripts |
|||
|
|||
# If the version information is not in the configure script, then we
|
|||
# assume that we are in a working directory. We use the vcs-version.sh
|
|||
# script in the scripts directory to generate an appropriate version
|
|||
# string. Currently the way things are setup we have to run this script
|
|||
# everytime we run make so the script needs to be as fast as possible.
|
|||
|
|||
ifeq (@PACKAGE_VERSION@,?) |
|||
project_ver:=$(shell $(scripts_dir)/vcs-version.sh $(src_dir)) |
|||
else |
|||
project_ver:=@PACKAGE_VERSION@ |
|||
endif |
|||
|
|||
# Installation directories
|
|||
|
|||
prefix := @prefix@ |
|||
enable_stow := @enable_stow@ |
|||
|
|||
ifeq ($(enable_stow),yes) |
|||
stow_pkg_dir := $(prefix)/pkgs |
|||
DESTDIR ?= $(stow_pkg_dir)/$(project_name)-$(project_ver) |
|||
else |
|||
DESTDIR ?= $(prefix) |
|||
endif |
|||
|
|||
install_hdrs_dir := $(DESTDIR)/include/$(project_name) |
|||
install_libs_dir := $(DESTDIR)/lib/$(project_name) |
|||
install_exes_dir := $(DESTDIR)/bin |
|||
|
|||
#-------------------------------------------------------------------------
|
|||
# List of subprojects
|
|||
#-------------------------------------------------------------------------
|
|||
|
|||
sprojs := @subprojects@ |
|||
sprojs_enabled := @subprojects_enabled@ |
|||
|
|||
sprojs_include := -I. $(addprefix -I$(src_dir)/, $(sprojs_enabled)) |
|||
VPATH := $(addprefix $(src_dir)/, $(sprojs_enabled)) |
|||
|
|||
#-------------------------------------------------------------------------
|
|||
# Programs and flags
|
|||
#-------------------------------------------------------------------------
|
|||
|
|||
# C++ compiler
|
|||
# - CPPFLAGS : flags for the preprocessor (eg. -I,-D)
|
|||
# - CXXFLAGS : flags for C++ compiler (eg. -Wall,-g,-O3)
|
|||
|
|||
CC := @CC@ |
|||
CFLAGS := @CFLAGS@ |
|||
COMPILE := $(CC) -MMD -MP $(CFLAGS) \
|
|||
$(sprojs_include) |
|||
# Linker
|
|||
# - LDFLAGS : Flags for the linker (eg. -L)
|
|||
# - LIBS : Library flags (eg. -l)
|
|||
|
|||
LD := $(CC) |
|||
LDFLAGS := @LDFLAGS@ |
|||
LIBS := @LIBS@ |
|||
LINK := $(LD) $(LDFLAGS) -T $(src_dir)/pk/pk.ld |
|||
|
|||
# Library creation
|
|||
|
|||
AR := @AR@ |
|||
RANLIB := @RANLIB@ |
|||
|
|||
# Host simulator
|
|||
|
|||
RUN := @RUN@ |
|||
RUNFLAGS := @RUNFLAGS@ |
|||
|
|||
# Installation
|
|||
|
|||
MKINSTALLDIRS := $(scripts_dir)/mk-install-dirs.sh |
|||
INSTALL := @INSTALL@ |
|||
INSTALL_HDR := $(INSTALL) -m 444 |
|||
INSTALL_LIB := $(INSTALL) -m 644 |
|||
INSTALL_EXE := $(INSTALL) -m 555 |
|||
STOW := @stow@ |
|||
|
|||
#-------------------------------------------------------------------------
|
|||
# Include subproject makefile fragments
|
|||
#-------------------------------------------------------------------------
|
|||
|
|||
sprojs_mk = $(addsuffix .mk, $(sprojs_enabled)) |
|||
|
|||
-include $(sprojs_mk) |
|||
|
|||
dist_junk += $(sprojs_mk) |
|||
|
|||
#-------------------------------------------------------------------------
|
|||
# Reverse list helper function
|
|||
#-------------------------------------------------------------------------
|
|||
# This function is used by the subproject template to reverse the list
|
|||
# of dependencies. It uses recursion to perform the reversal.
|
|||
#
|
|||
# Arguments:
|
|||
# $(1) : space separated input list
|
|||
# retval : input list in reverse order
|
|||
#
|
|||
|
|||
reverse_list = $(call reverse_list_h,$(1),) |
|||
define reverse_list_h |
|||
$(if $(strip $(1)), \
|
|||
$(call reverse_list_h, \
|
|||
$(wordlist 2,$(words $(1)),$(1)), \
|
|||
$(firstword $(1)) $(2)), \
|
|||
$(2)) |
|||
endef |
|||
|
|||
#-------------------------------------------------------------------------
|
|||
# Template for per subproject rules
|
|||
#-------------------------------------------------------------------------
|
|||
# The template is instantiated for each of the subprojects. It relies on
|
|||
# subprojects defining a certain set of make variables which are all
|
|||
# prefixed with the subproject name. Since subproject names can have
|
|||
# dashes in them (and the make variables are assumed to only use
|
|||
# underscores) the template takes two arguments - one with the regular
|
|||
# subproject name and one with dashes replaced with underscores.
|
|||
#
|
|||
# Arguments:
|
|||
# $(1) : real subproject name (ie with dashes)
|
|||
# $(2) : normalized subproject name (ie dashes replaced with underscores)
|
|||
#
|
|||
|
|||
define subproject_template |
|||
|
|||
# In some (rare) cases, a subproject might not have any actual object
|
|||
# files. It might only include header files or program sources. To keep
|
|||
# things consistent we still want a library for this subproject, so in
|
|||
# this spectial case we create a dummy source file and thus the build
|
|||
# system will create a library for this subproject with just the
|
|||
# corresponding dummy object file.
|
|||
|
|||
ifeq ($$(strip $$($(2)_srcs)),) |
|||
$(2)_srcs += _$(1).c |
|||
$(2)_junk += _$(1).c |
|||
endif |
|||
|
|||
_$(1).c : |
|||
echo "int _$(2)( int arg ) { return arg; }" > $$@ |
|||
|
|||
# Build the object files for this subproject
|
|||
|
|||
$(2)_objs := $$(patsubst %.c, %.o, $$($(2)_srcs)) |
|||
$(2)_asm_objs := $$(patsubst %.S, %.o, $$($(2)_asm_srcs)) |
|||
$(2)_deps := $$(patsubst %.o, %.d, $$($(2)_objs)) |
|||
$$($(2)_objs) : %.o : %.c |
|||
$(COMPILE) -c $$< |
|||
$$($(2)_asm_objs) : %.o : %.S |
|||
$(COMPILE) -c $$< |
|||
|
|||
$(2)_junk += $$($(2)_objs) $$($(2)_deps) $$($(2)_asm_objs) |
|||
|
|||
# Build a library for this subproject
|
|||
|
|||
lib$(1).a : $$($(2)_objs) $$($(2)_asm_objs) |
|||
$(AR) rcv $$@ $$^ |
|||
$(RANLIB) $$@ |
|||
|
|||
$(2)_junk += lib$(1).a |
|||
|
|||
# Reverse the dependency list so that a given subproject only depends on
|
|||
# subprojects listed to its right. This is the correct order for linking
|
|||
# the list of subproject libraries.
|
|||
|
|||
$(2)_reverse_deps := $$(call reverse_list,$$($(2)_subproject_deps)) |
|||
|
|||
# Build unit tests
|
|||
|
|||
$(2)_test_objs := $$(patsubst %.c, %.o, $$($(2)_test_srcs)) |
|||
$(2)_test_deps := $$(patsubst %.o, %.d, $$($(2)_test_objs)) |
|||
$(2)_test_exes := $$(patsubst %.t.c, %-utst, $$($(2)_test_srcs)) |
|||
$(2)_test_outs := $$(patsubst %, %.out, $$($(2)_test_exes)) |
|||
$(2)_test_libs := $(1) $$($(2)_reverse_deps) utst |
|||
$(2)_test_libnames := $$(patsubst %, lib%.a, $$($(2)_test_libs)) |
|||
$(2)_test_libarg := -L. $$(patsubst %, -l%, $$($(2)_test_libs)) |
|||
|
|||
$$($(2)_test_objs) : %.o : %.c |
|||
$(COMPILE) -c $$< |
|||
|
|||
$$($(2)_test_exes) : %-utst : %.t.o $$($(2)_test_libnames) |
|||
$(LINK) -o $$@ $$< $$($(2)_test_libarg) $(LIBS) |
|||
|
|||
$(2)_deps += $$($(2)_test_deps) |
|||
$(2)_junk += \
|
|||
$$($(2)_test_objs) $$($(2)_test_deps) \
|
|||
$$($(2)_test_exes) *.junk-dat |
|||
|
|||
# Run unit tests
|
|||
|
|||
$$($(2)_test_outs) : %.out : % |
|||
$(RUN) $(RUNFLAGS) ./$$< default | tee $$@ |
|||
|
|||
$(2)_junk += $$($(2)_test_outs) |
|||
|
|||
# Build programs
|
|||
|
|||
$(2)_prog_objs := $$(patsubst %.c, %.o, $$($(2)_prog_srcs)) |
|||
$(2)_prog_deps := $$(patsubst %.o, %.d, $$($(2)_prog_objs)) |
|||
$(2)_prog_exes := $$(patsubst %.c, %, $$($(2)_prog_srcs)) |
|||
$(2)_prog_libs := $(1) $$($(2)_reverse_deps) |
|||
$(2)_prog_libnames := $$(patsubst %, lib%.a, $$($(2)_prog_libs)) |
|||
$(2)_prog_libarg := -L. $$(patsubst %, -l%, $$($(2)_prog_libs)) |
|||
|
|||
$$($(2)_prog_objs) : %.o : %.c |
|||
$(COMPILE) -c $$< |
|||
|
|||
$$($(2)_prog_exes) : % : %.o $$($(2)_prog_libnames) |
|||
$(LINK) -o $$@ $$< $$($(2)_prog_libarg) $(LIBS) |
|||
|
|||
$(2)_deps += $$($(2)_prog_deps) |
|||
$(2)_junk += $$($(2)_prog_objs) $$($(2)_prog_deps) $$($(2)_prog_exes) |
|||
|
|||
# Build programs which will be installed
|
|||
|
|||
$(2)_install_prog_objs := $$(patsubst %.c, %.o, $$($(2)_install_prog_srcs)) |
|||
$(2)_install_prog_deps := $$(patsubst %.o, %.d, $$($(2)_install_prog_objs)) |
|||
$(2)_install_prog_exes := $$(patsubst %.c, %, $$($(2)_install_prog_srcs)) |
|||
|
|||
$$($(2)_install_prog_objs) : %.o : %.c |
|||
$(COMPILE) -c $$< |
|||
|
|||
$$($(2)_install_prog_exes) : % : %.o $$($(2)_prog_libnames) |
|||
$(LINK) -o $$@ $$< $$($(2)_prog_libarg) $(LIBS) |
|||
|
|||
$(2)_deps += $$($(2)_install_prog_deps) |
|||
$(2)_junk += \
|
|||
$$($(2)_install_prog_objs) $$($(2)_install_prog_deps) \
|
|||
$$($(2)_install_prog_exes) |
|||
|
|||
# Subproject specific targets
|
|||
|
|||
all-$(1) : lib$(1).a $$($(2)_install_prog_exes) |
|||
|
|||
check-$(1) : $$($(2)_test_outs) |
|||
echo; grep -h -e'Unit Tests' -e'FAILED' -e'Segementation' $$^; echo |
|||
|
|||
clean-$(1) : |
|||
rm -rf $$($(2)_junk) |
|||
|
|||
.PHONY : all-$(1) check-$(1) clean-$(1) |
|||
|
|||
# Update running variables
|
|||
|
|||
libs += lib$(1).a |
|||
objs += $$($(2)_objs) |
|||
srcs += $$(addprefix $(src_dir)/$(1)/, $$($(2)_srcs)) |
|||
hdrs += $$(addprefix $(src_dir)/$(1)/, $$($(2)_hdrs)) |
|||
junk += $$($(2)_junk) |
|||
deps += $$($(2)_deps) |
|||
|
|||
test_outs += $$($(2)_test_outs) |
|||
|
|||
install_hdrs += $$(addprefix $(src_dir)/$(1)/, $$($(2)_hdrs)) |
|||
install_libs += lib$(1).a |
|||
install_exes += $$($(2)_install_prog_exes) |
|||
|
|||
endef |
|||
|
|||
# Iterate over the subprojects and call the template for each one
|
|||
|
|||
$(foreach sproj,$(sprojs_enabled), \ |
|||
$(eval $(call subproject_template,$(sproj),$(subst -,_,$(sproj))))) |
|||
|
|||
#-------------------------------------------------------------------------
|
|||
# Autodependency files
|
|||
#-------------------------------------------------------------------------
|
|||
|
|||
-include $(deps) |
|||
|
|||
deps : $(deps) |
|||
.PHONY : deps |
|||
|
|||
#-------------------------------------------------------------------------
|
|||
# Check
|
|||
#-------------------------------------------------------------------------
|
|||
|
|||
check : $(test_outs) |
|||
echo; grep -h -e'Unit Tests' -e'FAILED' -e'Segementation' $^; echo |
|||
|
|||
.PHONY : check |
|||
|
|||
#-------------------------------------------------------------------------
|
|||
# Installation
|
|||
#-------------------------------------------------------------------------
|
|||
|
|||
install-hdrs : $(install_hdrs) |
|||
$(MKINSTALLDIRS) $(install_hdrs_dir) |
|||
for file in $(install_hdrs); \
|
|||
do \
|
|||
$(INSTALL_HDR) $$file $(install_hdrs_dir); \
|
|||
done |
|||
|
|||
install-libs : $(install_libs) |
|||
$(MKINSTALLDIRS) $(install_libs_dir) |
|||
for file in $(install_libs); \
|
|||
do \
|
|||
$(INSTALL_LIB) $$file $(install_libs_dir); \
|
|||
done |
|||
|
|||
install-exes : $(install_exes) |
|||
$(MKINSTALLDIRS) $(install_exes_dir) |
|||
for file in $(install_exes); \
|
|||
do \
|
|||
$(INSTALL_EXE) $$file $(install_exes_dir); \
|
|||
done |
|||
|
|||
install : install-hdrs install-libs install-exes |
|||
ifeq ($(enable_stow),yes) |
|||
$(MKINSTALLDIRS) $(stow_pkg_dir) |
|||
cd $(stow_pkg_dir) && \
|
|||
$(STOW) --delete $(project_name)-* && \
|
|||
$(STOW) $(project_name)-$(project_ver) |
|||
endif |
|||
|
|||
.PHONY : install install-hdrs install-libs install-exes |
|||
|
|||
#-------------------------------------------------------------------------
|
|||
# Regenerate configure information
|
|||
#-------------------------------------------------------------------------
|
|||
|
|||
configure_prereq = \
|
|||
$(src_dir)/configure.ac \
|
|||
$(src_dir)/aclocal.m4 \
|
|||
$(join $(addprefix $(src_dir)/, $(sprojs_enabled)), \
|
|||
$(patsubst %, /%.ac, $(sprojs_enabled))) |
|||
|
|||
$(src_dir)/configure : $(configure_prereq) |
|||
cd $(src_dir) && autoconf && autoheader |
|||
|
|||
config.status : $(src_dir)/configure |
|||
./config.status --recheck |
|||
|
|||
sprojs_mk_in = \
|
|||
$(join $(addprefix $(src_dir)/, $(sprojs_enabled)), \
|
|||
$(patsubst %, /%.mk.in, $(sprojs_enabled))) |
|||
|
|||
Makefile : $(src_dir)/Makefile.in $(sprojs_mk_in) config.status |
|||
./config.status |
|||
|
|||
dist_junk += config.status config.h Makefile config.log |
|||
|
|||
#-------------------------------------------------------------------------
|
|||
# Distribution
|
|||
#-------------------------------------------------------------------------
|
|||
# The distribution tarball is named project-ver.tar.gz and it includes
|
|||
# both enabled and disabled subprojects.
|
|||
|
|||
dist_files = \
|
|||
$(sprojs) \
|
|||
README \
|
|||
style-guide.txt \
|
|||
mcppbs-uguide.txt \
|
|||
scripts \
|
|||
configure.ac \
|
|||
aclocal.m4 \
|
|||
configure \
|
|||
config.h.in \
|
|||
Makefile.in \
|
|||
|
|||
dist_dir := $(project_name)-$(project_ver) |
|||
dist_tgz := $(project_name)-$(project_ver).tar.gz |
|||
|
|||
# Notice that when we make the distribution we rewrite the configure.ac
|
|||
# script with the current version and we rerun autoconf in the new
|
|||
# source directory so that the distribution will have the proper version
|
|||
# information. We also rewrite the "Version : " line in the README.
|
|||
|
|||
dist : |
|||
rm -rf $(dist_dir) |
|||
mkdir $(dist_dir) |
|||
tar -C $(src_dir) -cf - $(dist_files) | tar -C $(dist_dir) -xpf - |
|||
sed -i.bak 's/^\(# Version :\).*/\1 $(project_ver)/' $(dist_dir)/README |
|||
sed -i.bak 's/\( proj_version,\).*/\1 [$(project_ver)])/' $(dist_dir)/configure.ac |
|||
cd $(dist_dir) && \
|
|||
autoconf && autoheader && \
|
|||
rm -rf autom4te.cache configure.ac.bak README.bak |
|||
tar -czvf $(dist_tgz) $(dist_dir) |
|||
rm -rf $(dist_dir) |
|||
|
|||
# You can use the distcheck target to try untarring the distribution and
|
|||
# then running configure, make, make check, and make distclean. A
|
|||
# "directory is not empty" error means distclean is not removing
|
|||
# everything.
|
|||
|
|||
distcheck : dist |
|||
rm -rf $(dist_dir) |
|||
tar -xzvf $(dist_tgz) |
|||
mkdir -p $(dist_dir)/build |
|||
cd $(dist_dir)/build; ../configure; make; make check; make distclean |
|||
rm -rf $(dist_dir) |
|||
|
|||
junk += $(project_name)-*.tar.gz |
|||
|
|||
.PHONY : dist distcheck |
|||
|
|||
#-------------------------------------------------------------------------
|
|||
# Default
|
|||
#-------------------------------------------------------------------------
|
|||
|
|||
all : $(install_hdrs) $(install_libs) $(install_exes) |
|||
.PHONY : all |
|||
|
|||
#-------------------------------------------------------------------------
|
|||
# Makefile debugging
|
|||
#-------------------------------------------------------------------------
|
|||
# This handy rule will display the contents of any make variable by
|
|||
# using the target debug-<varname>. So for example, make debug-junk will
|
|||
# display the contents of the junk variable.
|
|||
|
|||
debug-% : |
|||
@echo $* = $($*) |
|||
|
|||
#-------------------------------------------------------------------------
|
|||
# Clean up junk
|
|||
#-------------------------------------------------------------------------
|
|||
|
|||
clean : |
|||
rm -rf *~ \#* $(junk) |
|||
|
|||
distclean : |
|||
rm -rf *~ \#* $(junk) $(dist_junk) |
|||
|
|||
.PHONY : clean distclean |
|||
@ -0,0 +1,37 @@ |
|||
========================================================================== |
|||
Modular C++ Build System Template |
|||
========================================================================== |
|||
# Author : Christopher Batten |
|||
# Date : September 24, 2008 |
|||
# Version : (under version control) |
|||
|
|||
This is a template for the Modular C++ Build System. Please refer to the |
|||
following documentation for more information on the build system: |
|||
|
|||
- 'mcppbs-uguide.txt' : Modular C++ Build System User Guide |
|||
- 'utst/utst-uguide.txt' : Unit Testing Framework User Guide |
|||
- 'style-guide.txt' : C++ Coding Style Guide |
|||
|
|||
Developers should eventually replace this 'README' file with information |
|||
on their new project. It is recommended that the new 'README' file keep |
|||
pointers to the above documentation so that end-users can learn about |
|||
the build system. You may also want to keep the version information |
|||
around so that you know what version of the build system you are using. |
|||
|
|||
-------------------------------------------------------------------------- |
|||
Template Instantiation |
|||
-------------------------------------------------------------------------- |
|||
|
|||
- Update project metadata (name, maintainer, etc) in 'configure.ac' |
|||
- Run 'autoconf && autoheader' in project's root directory |
|||
- Add subprojects and update the list in 'configure.ac' |
|||
|
|||
-------------------------------------------------------------------------- |
|||
Build Steps |
|||
-------------------------------------------------------------------------- |
|||
|
|||
% mkdir build |
|||
% cd build |
|||
% ../configure |
|||
% make |
|||
|
|||
@ -0,0 +1,345 @@ |
|||
#========================================================================= |
|||
# Local Autoconf Macros |
|||
#========================================================================= |
|||
# This file contains the macros for the Modular C++ Build System and |
|||
# additional autoconf macros which developers can use in their |
|||
# configure.ac scripts. Please read the documentation in |
|||
# 'mcppbs-doc.txt' for more details on how the Modular C++ Build System |
|||
# works. The documenation for each macro should include information |
|||
# about the author, date, and copyright. |
|||
|
|||
#------------------------------------------------------------------------- |
|||
# MCPPBS_PROG_INSTALL |
|||
#------------------------------------------------------------------------- |
|||
# This macro will add an --enable-stow command line option to the |
|||
# configure script. When enabled, this macro will first check to see if |
|||
# the stow program is available and if so it will set the $stow shell |
|||
# variable to the binary name and the $enable_stow shell variable to |
|||
# "yes". These variables can be used in a makefile to conditionally use |
|||
# stow for installation. |
|||
# |
|||
# This macro uses two environment variables to help setup default stow |
|||
# locations. The $STOW_PREFIX is used for stowing native built packages. |
|||
# The packages are staged in $STOW_PREFIX/pkgs and then symlinks are |
|||
# created from within $STOW_PREFIX into the pkgs subdirectory. If you |
|||
# only do native builds then this is all you need to set. If you don't |
|||
# set $STOW_PREFIX then the default is just the normal default prefix |
|||
# which is almost always /usr/local. |
|||
# |
|||
# For non-native builds we probably want to install the packages in a |
|||
# different location which includes the host architecture name as part |
|||
# of the prefix. For these kind of builds, we can specify the $STOW_ROOT |
|||
# environment variable and the effective prefix will be |
|||
# $STOW_ROOT/${host_alias} where ${host_alias} is specified on the |
|||
# configure command line with "--host". |
|||
# |
|||
# Here is an example setup: |
|||
# |
|||
# STOW_ROOT="$HOME/install" |
|||
# STOW_ARCH="i386-macosx10.4" |
|||
# STOW_PREFIX="${STOW_ROOT}/${STOW_ARCH}" |
|||
# |
|||
|
|||
AC_DEFUN([MCPPBS_PROG_INSTALL], |
|||
[ |
|||
|
|||
# Configure command line option |
|||
|
|||
AC_ARG_ENABLE(stow, |
|||
AS_HELP_STRING(--enable-stow,[Enable stow-based install]), |
|||
[enable_stow="yes"],[enable_stow="no"]) |
|||
|
|||
AC_SUBST([enable_stow]) |
|||
|
|||
# Environment variables |
|||
|
|||
AC_ARG_VAR([STOW_ROOT], [Root for non-native stow-based installs]) |
|||
AC_ARG_VAR([STOW_PREFIX], [Prefix for stow-based installs]) |
|||
|
|||
# Check for install script |
|||
|
|||
AC_PROG_INSTALL |
|||
|
|||
# Deterimine if native build and set prefix appropriately |
|||
|
|||
AS_IF([ test ${enable_stow} = "yes" ], |
|||
[ |
|||
AC_CHECK_PROGS([stow],[stow],[no]) |
|||
AS_IF([ test ${stow} = "no" ], |
|||
[ |
|||
AC_MSG_ERROR([Cannot use --enable-stow since stow is not available]) |
|||
]) |
|||
|
|||
# Check if native or non-native build |
|||
|
|||
AS_IF([ test "${build}" = "${host}" ], |
|||
[ |
|||
|
|||
# build == host so this is a native build. Make sure --prefix not |
|||
# set and $STOW_PREFIX is set, then set prefix=$STOW_PREFIX. |
|||
|
|||
AS_IF([ test "${prefix}" = "NONE" && test -n "${STOW_PREFIX}" ], |
|||
[ |
|||
prefix="${STOW_PREFIX}" |
|||
AC_MSG_NOTICE([Using \$STOW_PREFIX from environment]) |
|||
AC_MSG_NOTICE([prefix=${prefix}]) |
|||
]) |
|||
|
|||
],[ |
|||
|
|||
# build != host so this is a non-native build. Make sure --prefix |
|||
# not set and $STOW_ROOT is set, then set |
|||
# prefix=$STOW_ROOT/${host_alias}. |
|||
|
|||
AS_IF([ test "${prefix}" = "NONE" && test -n "${STOW_ROOT}" ], |
|||
[ |
|||
prefix="${STOW_ROOT}/${host_alias}" |
|||
AC_MSG_NOTICE([Using \$STOW_ROOT from environment]) |
|||
AC_MSG_NOTICE([prefix=${prefix}]) |
|||
]) |
|||
|
|||
]) |
|||
|
|||
]) |
|||
|
|||
]) |
|||
|
|||
#------------------------------------------------------------------------- |
|||
# MCPPBS_PROG_RUN |
|||
# ------------------------------------------------------------------------- |
|||
# If we are doing a non-native build then we look for an isa simulator |
|||
# to use for running tests. We set the RUN substitution variable to be |
|||
# empty for native builds or to the name of the isa simulator for |
|||
# non-native builds. Thus a makefile can run compiled programs |
|||
# regardless if we are doing a native or non-native build like this: |
|||
# |
|||
# $(RUN) $(RUNFLAGS) ./test-program |
|||
# |
|||
|
|||
AC_DEFUN([MCPPBS_PROG_RUN], |
|||
[ |
|||
AS_IF([ test "${build}" != "${host}" ], |
|||
[ |
|||
AC_CHECK_TOOLS([RUN],[isa-run run],[no]) |
|||
AS_IF([ test ${RUN} = "no" ], |
|||
[ |
|||
AC_MSG_ERROR([Cannot find simulator for target ${target_alias}]) |
|||
]) |
|||
],[ |
|||
RUN="" |
|||
]) |
|||
AC_SUBST([RUN]) |
|||
AC_SUBST([RUNFLAGS]) |
|||
]) |
|||
|
|||
#------------------------------------------------------------------------- |
|||
# MCPPBS_SUBPROJECTS([ sproj1, sproj2, ... ]) |
|||
#------------------------------------------------------------------------- |
|||
# The developer should call this macro with a list of the subprojects |
|||
# which make up this project. One should order the list such that any |
|||
# given subproject only depends on subprojects listed before it. The |
|||
# subproject names can also include an * suffix which indicates that |
|||
# this is an optional subproject. Optional subprojects are only included |
|||
# as part of the project build if enabled on the configure command line |
|||
# with a --enable-<subproject> flag. The user can also specify that all |
|||
# optional subprojects should be included in the build with the |
|||
# --enable-optional-subprojects flag. |
|||
# |
|||
# Subproject names can also include a ** suffix which indicates that it |
|||
# is an optional subproject, but there is a group with the same name. |
|||
# Thus the --enable-<sproj> command line option will enable not just the |
|||
# subproject sproj but all of the subprojects which are in the group. |
|||
# There is no error checking to make sure that if you use the ** suffix |
|||
# you actually define a group so be careful. |
|||
# |
|||
# Both required and optional subprojects should have a 'subproject.ac' |
|||
# file. The script's filename should be the abbreivated subproject name |
|||
# (assuming the subproject name is sproj then we would use 'sproj.ac') |
|||
# The MCPPBS_SUBPROJECTS macro includes the 'subproject.ac' files for |
|||
# enabled subprojects. Whitespace and newlines are allowed within the |
|||
# list. |
|||
# |
|||
# Author : Christopher Batten |
|||
# Date : September 10, 2008 |
|||
|
|||
AC_DEFUN([MCPPBS_SUBPROJECTS], |
|||
[ |
|||
|
|||
# Add command line argument to enable all optional subprojects |
|||
|
|||
AC_ARG_ENABLE(optional-subprojects, |
|||
AS_HELP_STRING([--enable-optional-subprojects], |
|||
[Enable all optional subprojects])) |
|||
|
|||
# Loop through the subprojects given in the macro argument |
|||
|
|||
m4_foreach([MCPPBS_SPROJ],[$1], |
|||
[ |
|||
|
|||
# Determine if this is a required or an optional subproject |
|||
|
|||
m4_define([MCPPBS_IS_REQ], |
|||
m4_bmatch(MCPPBS_SPROJ,[\*+],[false],[true])) |
|||
|
|||
# Determine if there is a group with the same name |
|||
|
|||
m4_define([MCPPBS_IS_GROUP], |
|||
m4_bmatch(MCPPBS_SPROJ,[\*\*],[true],[false])) |
|||
|
|||
# Create variations of the subproject name suitable for use as a CPP |
|||
# enabled define, a shell enabled variable, and a shell function |
|||
|
|||
m4_define([MCPPBS_SPROJ_NORM], |
|||
m4_normalize(m4_bpatsubsts(MCPPBS_SPROJ,[*],[]))) |
|||
|
|||
m4_define([MCPPBS_SPROJ_DEFINE], |
|||
m4_toupper(m4_bpatsubst(MCPPBS_SPROJ_NORM[]_ENABLED,[-],[_]))) |
|||
|
|||
m4_define([MCPPBS_SPROJ_FUNC], |
|||
m4_bpatsubst(_mpbp_[]MCPPBS_SPROJ_NORM[]_configure,[-],[_])) |
|||
|
|||
m4_define([MCPPBS_SPROJ_UNDERSCORES], |
|||
m4_bpatsubsts(MCPPBS_SPROJ,[-],[_])) |
|||
|
|||
m4_define([MCPPBS_SPROJ_SHVAR], |
|||
m4_bpatsubst(enable_[]MCPPBS_SPROJ_NORM[]_sproj,[-],[_])) |
|||
|
|||
# Add subproject to our running list |
|||
|
|||
subprojects="$subprojects MCPPBS_SPROJ_NORM" |
|||
|
|||
# Process the subproject appropriately. If enabled add it to the |
|||
# $enabled_subprojects running shell variable, set a |
|||
# SUBPROJECT_ENABLED C define, and include the appropriate |
|||
# 'subproject.ac'. |
|||
|
|||
m4_if(MCPPBS_IS_REQ,[true], |
|||
[ |
|||
AC_MSG_NOTICE([configuring default subproject : MCPPBS_SPROJ_NORM]) |
|||
AC_CONFIG_FILES(MCPPBS_SPROJ_NORM[].mk:MCPPBS_SPROJ_NORM[]/MCPPBS_SPROJ_NORM[].mk.in) |
|||
MCPPBS_SPROJ_SHVAR="yes" |
|||
subprojects_enabled="$subprojects_enabled MCPPBS_SPROJ_NORM" |
|||
AC_DEFINE(MCPPBS_SPROJ_DEFINE,, |
|||
[Define if subproject MCPPBS_SPROJ_NORM is enabled]) |
|||
m4_include(MCPPBS_SPROJ_NORM[]/MCPPBS_SPROJ_NORM[].ac) |
|||
],[ |
|||
|
|||
# For optional subprojects we capture the 'subproject.ac' as a |
|||
# shell function so that in the MCPPBS_GROUP macro we can just |
|||
# call this shell function instead of reading in 'subproject.ac' |
|||
# again. |
|||
|
|||
MCPPBS_SPROJ_FUNC () |
|||
{ |
|||
AC_MSG_NOTICE([configuring optional subproject : MCPPBS_SPROJ_NORM]) |
|||
AC_CONFIG_FILES(MCPPBS_SPROJ_NORM[].mk:MCPPBS_SPROJ_NORM[]/MCPPBS_SPROJ_NORM[].mk.in) |
|||
MCPPBS_SPROJ_SHVAR="yes" |
|||
subprojects_enabled="$subprojects_enabled MCPPBS_SPROJ_NORM" |
|||
AC_DEFINE(MCPPBS_SPROJ_DEFINE,, |
|||
[Define if subproject MCPPBS_SPROJ_NORM is enabled]) |
|||
m4_include(MCPPBS_SPROJ_NORM[]/MCPPBS_SPROJ_NORM[].ac) |
|||
}; |
|||
|
|||
# Optional subprojects add --enable-subproject command line |
|||
# options, _if_ the subproject name is not also a group name. |
|||
|
|||
m4_if(MCPPBS_IS_GROUP,[false], |
|||
[ |
|||
AC_ARG_ENABLE(MCPPBS_SPROJ_NORM, |
|||
AS_HELP_STRING(--enable-MCPPBS_SPROJ_NORM, |
|||
[Subproject MCPPBS_SPROJ_NORM]), |
|||
[MCPPBS_SPROJ_SHVAR="yes"],[MCPPBS_SPROJ_SHVAR="no"]) |
|||
|
|||
AS_IF([test "$MCPPBS_SPROJ_SHVAR" = "yes"], |
|||
[ |
|||
eval "MCPPBS_SPROJ_FUNC" |
|||
],[ |
|||
AC_MSG_NOTICE([processing optional subproject : MCPPBS_SPROJ_NORM]) |
|||
]) |
|||
|
|||
],[ |
|||
|
|||
# If the subproject name is also a group name then we need to |
|||
# make sure that we set the shell variable for that subproject to |
|||
# no so that the group code knows we haven't run it yet. |
|||
|
|||
AC_MSG_NOTICE([processing optional subproject : MCPPBS_SPROJ_NORM]) |
|||
MCPPBS_SPROJ_SHVAR="no" |
|||
|
|||
]) |
|||
|
|||
# Always execute the subproject configure code if we are enabling |
|||
# all subprojects. |
|||
|
|||
AS_IF([ test "$enable_optional_subprojects" = "yes" \ |
|||
&& test "$MCPPBS_SPROJ_SHVAR" = "no" ], |
|||
[ |
|||
eval "MCPPBS_SPROJ_FUNC" |
|||
]) |
|||
|
|||
]) |
|||
|
|||
]) |
|||
|
|||
# Output make variables |
|||
|
|||
AC_SUBST([subprojects]) |
|||
AC_SUBST([subprojects_enabled]) |
|||
|
|||
]) |
|||
|
|||
#------------------------------------------------------------------------- |
|||
# MCPPBS_GROUP( [group-name], [ sproj1, sproj2, ... ] ) |
|||
#------------------------------------------------------------------------- |
|||
# This macro creates a subproject group with the given group-name. When |
|||
# a user specifies --enable-<group-name> the listed subprojects will be |
|||
# enabled. Groups can have the same name as a subproject and in that |
|||
# case whenever a user specifies --enable-<subproject> the subprojects |
|||
# listed in the corresponding group will also be enabled. Groups are |
|||
# useful for specifying related subprojects which are usually enabled |
|||
# together, as well as for specifying that a specific optional |
|||
# subproject has dependencies on other optional subprojects. |
|||
# |
|||
# Author : Christopher Batten |
|||
# Date : September 10, 2008 |
|||
|
|||
AC_DEFUN([MCPPBS_GROUP], |
|||
[ |
|||
|
|||
m4_define([MCPPBS_GROUP_NORM], |
|||
m4_normalize([$1])) |
|||
|
|||
m4_define([MCPPBS_GROUP_SHVAR], |
|||
m4_bpatsubst(enable_[]MCPPBS_GROUP_NORM[]_group,[-],[_])) |
|||
|
|||
AC_ARG_ENABLE(MCPPBS_GROUP_NORM, |
|||
AS_HELP_STRING(--enable-MCPPBS_GROUP_NORM, |
|||
[Group MCPPBS_GROUP_NORM: $2]), |
|||
[MCPPBS_GROUP_SHVAR="yes"],[MCPPBS_GROUP_SHVAR="no"]) |
|||
|
|||
AS_IF([test "$MCPPBS_GROUP_SHVAR" = "yes" ], |
|||
[ |
|||
AC_MSG_NOTICE([configuring optional group : MCPPBS_GROUP_NORM]) |
|||
]) |
|||
|
|||
m4_foreach([MCPPBS_SPROJ],[$2], |
|||
[ |
|||
|
|||
m4_define([MCPPBS_SPROJ_NORM], |
|||
m4_normalize(MCPPBS_SPROJ)) |
|||
|
|||
m4_define([MCPPBS_SPROJ_SHVAR], |
|||
m4_bpatsubst(enable_[]MCPPBS_SPROJ_NORM[]_sproj,[-],[_])) |
|||
|
|||
m4_define([MCPPBS_SPROJ_FUNC], |
|||
m4_bpatsubst(_mpbp_[]MCPPBS_SPROJ_NORM[]_configure,[-],[_])) |
|||
|
|||
AS_IF([ test "$MCPPBS_GROUP_SHVAR" = "yes" \ |
|||
&& test "$MCPPBS_SPROJ_SHVAR" = "no" ], |
|||
[ |
|||
eval "MCPPBS_SPROJ_FUNC" |
|||
]) |
|||
|
|||
]) |
|||
|
|||
]) |
|||
@ -0,0 +1,25 @@ |
|||
/* config.h.in. Generated from configure.ac by autoheader. */ |
|||
|
|||
/* Define to the address where bug reports for this package should be sent. */ |
|||
#undef PACKAGE_BUGREPORT |
|||
|
|||
/* Define to the full name of this package. */ |
|||
#undef PACKAGE_NAME |
|||
|
|||
/* Define to the full name and version of this package. */ |
|||
#undef PACKAGE_STRING |
|||
|
|||
/* Define to the one symbol short name of this package. */ |
|||
#undef PACKAGE_TARNAME |
|||
|
|||
/* Define to the home page for this package. */ |
|||
#undef PACKAGE_URL |
|||
|
|||
/* Define to the version of this package. */ |
|||
#undef PACKAGE_VERSION |
|||
|
|||
/* Define if subproject MCPPBS_SPROJ_NORM is enabled */ |
|||
#undef PK_ENABLED |
|||
|
|||
/* Define to 1 if you have the ANSI C header files. */ |
|||
#undef STDC_HEADERS |
|||
File diff suppressed because it is too large
@ -0,0 +1,102 @@ |
|||
#========================================================================= |
|||
# Toplevel configure.ac for the Modular C++ Build System |
|||
#========================================================================= |
|||
# Please read the documenation in 'mcppbs-doc.txt' for more details on |
|||
# how the Modular C++ Build System works. For most new projects, a |
|||
# developer will only need to make the following changes: |
|||
# |
|||
# - change the project metadata listed right below |
|||
# - update the list of subprojects via the 'MCPPBS_SUBPROJECTS' macro |
|||
# - possibly add subproject groups if needed to ease configuration |
|||
# - add more configure checks for platform specific configuration |
|||
# |
|||
|
|||
#------------------------------------------------------------------------- |
|||
# Project metadata |
|||
#------------------------------------------------------------------------- |
|||
|
|||
m4_define( proj_name, [RISC-V Proxy Kernel]) |
|||
m4_define( proj_maintainer, [Andrew Waterman]) |
|||
m4_define( proj_abbreviation, [riscv-pk]) |
|||
|
|||
#------------------------------------------------------------------------- |
|||
# Project version information |
|||
#------------------------------------------------------------------------- |
|||
# Version information is meant to be managed through a version control |
|||
# system's tags and revision numbers. In a working copy the version will |
|||
# not be defined here (you should just use the version control system's |
|||
# mechanisms). When we make a distribution then we can set the version |
|||
# here as formed by the scripts/vcs-version.sh script so that the |
|||
# distribution knows what version it came from. If you are not using |
|||
# version control then it is fine to set this directly. |
|||
|
|||
m4_define( proj_version, [?]) |
|||
|
|||
#------------------------------------------------------------------------- |
|||
# Setup |
|||
#------------------------------------------------------------------------- |
|||
|
|||
AC_INIT(proj_name,proj_version,proj_maintainer,proj_abbreviation) |
|||
AC_CONFIG_SRCDIR([pk/pk.h]) |
|||
AC_CONFIG_AUX_DIR([scripts]) |
|||
AC_CANONICAL_BUILD |
|||
AC_CANONICAL_HOST |
|||
|
|||
#------------------------------------------------------------------------- |
|||
# Checks for programs |
|||
#------------------------------------------------------------------------- |
|||
|
|||
AC_PROG_CC |
|||
AC_PROG_CXX |
|||
AC_CHECK_TOOL([AR],[ar]) |
|||
AC_CHECK_TOOL([RANLIB],[ranlib]) |
|||
|
|||
#------------------------------------------------------------------------- |
|||
# MCPPBS specific program checks |
|||
#------------------------------------------------------------------------- |
|||
# These macros check to see if we can do a stow-based install and also |
|||
# check for an isa simulator suitable for running the unit test programs |
|||
# via the makefile. |
|||
|
|||
MCPPBS_PROG_INSTALL |
|||
MCPPBS_PROG_RUN |
|||
|
|||
#------------------------------------------------------------------------- |
|||
# Checks for header files |
|||
#------------------------------------------------------------------------- |
|||
|
|||
AC_HEADER_STDC |
|||
|
|||
#------------------------------------------------------------------------- |
|||
# Default compiler flags |
|||
#------------------------------------------------------------------------- |
|||
|
|||
AC_SUBST([CFLAGS], ["-Wall -O3 -std=gnu99"]) |
|||
|
|||
#------------------------------------------------------------------------- |
|||
# MCPPBS subproject list |
|||
#------------------------------------------------------------------------- |
|||
# Order list so that subprojects only depend on those listed earlier. |
|||
# The '*' suffix indicates an optional subproject. The '**' suffix |
|||
# indicates an optional subproject which is also the name of a group. |
|||
|
|||
MCPPBS_SUBPROJECTS([ pk ]) |
|||
|
|||
#------------------------------------------------------------------------- |
|||
# MCPPBS subproject groups |
|||
#------------------------------------------------------------------------- |
|||
# If a group has the same name as a subproject then you must add the |
|||
# '**' suffix in the subproject list above. The list of subprojects in a |
|||
# group should be ordered so that subprojets only depend on those listed |
|||
# earlier. Here is an example: |
|||
# |
|||
# MCPPBS_GROUP( [group-name], [sproja,sprojb,...] ) |
|||
# |
|||
|
|||
#------------------------------------------------------------------------- |
|||
# Output |
|||
#------------------------------------------------------------------------- |
|||
|
|||
AC_CONFIG_HEADERS([config.h]) |
|||
AC_CONFIG_FILES([Makefile]) |
|||
AC_OUTPUT |
|||
@ -1,6 +1,6 @@ |
|||
#include "pcr.h" |
|||
|
|||
.text |
|||
.section boottext |
|||
.global __start |
|||
.ent __start |
|||
__start: |
|||
Binary file not shown.
@ -0,0 +1,20 @@ |
|||
pk_subproject_deps = \
|
|||
|
|||
pk_hdrs = \
|
|||
pk.h \
|
|||
|
|||
pk_srcs = \
|
|||
pk.c \
|
|||
file.c \
|
|||
syscall.c \
|
|||
handlers.c \
|
|||
frontend.c \
|
|||
|
|||
pk_asm_srcs = \
|
|||
entry.S \
|
|||
boot.S \
|
|||
|
|||
pk_test_srcs = |
|||
|
|||
pk_install_prog_srcs = \
|
|||
riscv-pk.c \
|
|||
@ -0,0 +1,6 @@ |
|||
// force the linker to pull in our __start from boot.S.
|
|||
void* dummy() |
|||
{ |
|||
extern void __start(); |
|||
return &__start; |
|||
} |
|||
File diff suppressed because it is too large
File diff suppressed because it is too large
@ -0,0 +1,238 @@ |
|||
#! /bin/sh |
|||
# |
|||
# install - install a program, script, or datafile |
|||
# This comes from X11R5. |
|||
# |
|||
# Calling this script install-sh is preferred over install.sh, to prevent |
|||
# `make' implicit rules from creating a file called install from it |
|||
# when there is no Makefile. |
|||
# |
|||
# This script is compatible with the BSD install script, but was written |
|||
# from scratch. |
|||
# |
|||
|
|||
|
|||
# set DOITPROG to echo to test this script |
|||
|
|||
# Don't use :- since 4.3BSD and earlier shells don't like it. |
|||
doit="${DOITPROG-}" |
|||
|
|||
|
|||
# put in absolute paths if you don't have them in your path; or use env. vars. |
|||
|
|||
mvprog="${MVPROG-mv}" |
|||
cpprog="${CPPROG-cp}" |
|||
chmodprog="${CHMODPROG-chmod}" |
|||
chownprog="${CHOWNPROG-chown}" |
|||
chgrpprog="${CHGRPPROG-chgrp}" |
|||
stripprog="${STRIPPROG-strip}" |
|||
rmprog="${RMPROG-rm}" |
|||
mkdirprog="${MKDIRPROG-mkdir}" |
|||
|
|||
tranformbasename="" |
|||
transform_arg="" |
|||
instcmd="$mvprog" |
|||
chmodcmd="$chmodprog 0755" |
|||
chowncmd="" |
|||
chgrpcmd="" |
|||
stripcmd="" |
|||
rmcmd="$rmprog -f" |
|||
mvcmd="$mvprog" |
|||
src="" |
|||
dst="" |
|||
dir_arg="" |
|||
|
|||
while [ x"$1" != x ]; do |
|||
case $1 in |
|||
-c) instcmd="$cpprog" |
|||
shift |
|||
continue;; |
|||
|
|||
-d) dir_arg=true |
|||
shift |
|||
continue;; |
|||
|
|||
-m) chmodcmd="$chmodprog $2" |
|||
shift |
|||
shift |
|||
continue;; |
|||
|
|||
-o) chowncmd="$chownprog $2" |
|||
shift |
|||
shift |
|||
continue;; |
|||
|
|||
-g) chgrpcmd="$chgrpprog $2" |
|||
shift |
|||
shift |
|||
continue;; |
|||
|
|||
-s) stripcmd="$stripprog" |
|||
shift |
|||
continue;; |
|||
|
|||
-t=*) transformarg=`echo $1 | sed 's/-t=//'` |
|||
shift |
|||
continue;; |
|||
|
|||
-b=*) transformbasename=`echo $1 | sed 's/-b=//'` |
|||
shift |
|||
continue;; |
|||
|
|||
*) if [ x"$src" = x ] |
|||
then |
|||
src=$1 |
|||
else |
|||
# this colon is to work around a 386BSD /bin/sh bug |
|||
: |
|||
dst=$1 |
|||
fi |
|||
shift |
|||
continue;; |
|||
esac |
|||
done |
|||
|
|||
if [ x"$src" = x ] |
|||
then |
|||
echo "install: no input file specified" |
|||
exit 1 |
|||
else |
|||
true |
|||
fi |
|||
|
|||
if [ x"$dir_arg" != x ]; then |
|||
dst=$src |
|||
src="" |
|||
|
|||
if [ -d $dst ]; then |
|||
instcmd=: |
|||
else |
|||
instcmd=mkdir |
|||
fi |
|||
else |
|||
|
|||
# Waiting for this to be detected by the "$instcmd $src $dsttmp" command |
|||
# might cause directories to be created, which would be especially bad |
|||
# if $src (and thus $dsttmp) contains '*'. |
|||
|
|||
if [ -f $src -o -d $src ] |
|||
then |
|||
true |
|||
else |
|||
echo "install: $src does not exist" |
|||
exit 1 |
|||
fi |
|||
|
|||
if [ x"$dst" = x ] |
|||
then |
|||
echo "install: no destination specified" |
|||
exit 1 |
|||
else |
|||
true |
|||
fi |
|||
|
|||
# If destination is a directory, append the input filename; if your system |
|||
# does not like double slashes in filenames, you may need to add some logic |
|||
|
|||
if [ -d $dst ] |
|||
then |
|||
dst="$dst"/`basename $src` |
|||
else |
|||
true |
|||
fi |
|||
fi |
|||
|
|||
## this sed command emulates the dirname command |
|||
dstdir=`echo $dst | sed -e 's,[^/]*$,,;s,/$,,;s,^$,.,'` |
|||
|
|||
# Make sure that the destination directory exists. |
|||
# this part is taken from Noah Friedman's mkinstalldirs script |
|||
|
|||
# Skip lots of stat calls in the usual case. |
|||
if [ ! -d "$dstdir" ]; then |
|||
defaultIFS=' |
|||
' |
|||
IFS="${IFS-${defaultIFS}}" |
|||
|
|||
oIFS="${IFS}" |
|||
# Some sh's can't handle IFS=/ for some reason. |
|||
IFS='%' |
|||
set - `echo ${dstdir} | sed -e 's@/@%@g' -e 's@^%@/@'` |
|||
IFS="${oIFS}" |
|||
|
|||
pathcomp='' |
|||
|
|||
while [ $# -ne 0 ] ; do |
|||
pathcomp="${pathcomp}${1}" |
|||
shift |
|||
|
|||
if [ ! -d "${pathcomp}" ] ; |
|||
then |
|||
$mkdirprog "${pathcomp}" |
|||
else |
|||
true |
|||
fi |
|||
|
|||
pathcomp="${pathcomp}/" |
|||
done |
|||
fi |
|||
|
|||
if [ x"$dir_arg" != x ] |
|||
then |
|||
$doit $instcmd $dst && |
|||
|
|||
if [ x"$chowncmd" != x ]; then $doit $chowncmd $dst; else true ; fi && |
|||
if [ x"$chgrpcmd" != x ]; then $doit $chgrpcmd $dst; else true ; fi && |
|||
if [ x"$stripcmd" != x ]; then $doit $stripcmd $dst; else true ; fi && |
|||
if [ x"$chmodcmd" != x ]; then $doit $chmodcmd $dst; else true ; fi |
|||
else |
|||
|
|||
# If we're going to rename the final executable, determine the name now. |
|||
|
|||
if [ x"$transformarg" = x ] |
|||
then |
|||
dstfile=`basename $dst` |
|||
else |
|||
dstfile=`basename $dst $transformbasename | |
|||
sed $transformarg`$transformbasename |
|||
fi |
|||
|
|||
# don't allow the sed command to completely eliminate the filename |
|||
|
|||
if [ x"$dstfile" = x ] |
|||
then |
|||
dstfile=`basename $dst` |
|||
else |
|||
true |
|||
fi |
|||
|
|||
# Make a temp file name in the proper directory. |
|||
|
|||
dsttmp=$dstdir/#inst.$$# |
|||
|
|||
# Move or copy the file name to the temp name |
|||
|
|||
$doit $instcmd $src $dsttmp && |
|||
|
|||
trap "rm -f ${dsttmp}" 0 && |
|||
|
|||
# and set any options; do chmod last to preserve setuid bits |
|||
|
|||
# If any of these fail, we abort the whole thing. If we want to |
|||
# ignore errors from any of these, just make sure not to ignore |
|||
# errors from the above "$doit $instcmd $src $dsttmp" command. |
|||
|
|||
if [ x"$chowncmd" != x ]; then $doit $chowncmd $dsttmp; else true;fi && |
|||
if [ x"$chgrpcmd" != x ]; then $doit $chgrpcmd $dsttmp; else true;fi && |
|||
if [ x"$stripcmd" != x ]; then $doit $stripcmd $dsttmp; else true;fi && |
|||
if [ x"$chmodcmd" != x ]; then $doit $chmodcmd $dsttmp; else true;fi && |
|||
|
|||
# Now rename the file to the real destination. |
|||
|
|||
$doit $rmcmd -f $dstdir/$dstfile && |
|||
$doit $mvcmd $dsttmp $dstdir/$dstfile |
|||
|
|||
fi && |
|||
|
|||
|
|||
exit 0 |
|||
@ -0,0 +1,40 @@ |
|||
#! /bin/sh |
|||
# mkinstalldirs --- make directory hierarchy |
|||
# Author: Noah Friedman <friedman@prep.ai.mit.edu> |
|||
# Created: 1993-05-16 |
|||
# Public domain |
|||
|
|||
# $Id: mkinstalldirs,v 1.1 2003/09/09 22:24:03 mhampton Exp $ |
|||
|
|||
errstatus=0 |
|||
|
|||
for file |
|||
do |
|||
set fnord `echo ":$file" | sed -ne 's/^:\//#/;s/^://;s/\// /g;s/^#/\//;p'` |
|||
shift |
|||
|
|||
pathcomp= |
|||
for d |
|||
do |
|||
pathcomp="$pathcomp$d" |
|||
case "$pathcomp" in |
|||
-* ) pathcomp=./$pathcomp ;; |
|||
esac |
|||
|
|||
if test ! -d "$pathcomp"; then |
|||
echo "mkdir $pathcomp" 1>&2 |
|||
|
|||
mkdir "$pathcomp" || lasterr=$? |
|||
|
|||
if test ! -d "$pathcomp"; then |
|||
errstatus=$lasterr |
|||
fi |
|||
fi |
|||
|
|||
pathcomp="$pathcomp/" |
|||
done |
|||
done |
|||
|
|||
exit $errstatus |
|||
|
|||
# mkinstalldirs ends here |
|||
@ -0,0 +1,117 @@ |
|||
#!/bin/bash |
|||
#========================================================================= |
|||
# vcs-version.sh [options] [src-dir] |
|||
#========================================================================= |
|||
# |
|||
# -h Display this message |
|||
# -v Verbose mode |
|||
# |
|||
# This script will create a version string by querying a version control |
|||
# system. The string is appropriate for use in installations and |
|||
# distributions. Currently this script assumes we are using git as our |
|||
# version control system but it would be possible to check and see if we |
|||
# are using an alternative version control system and create a version |
|||
# string appropriately. |
|||
# |
|||
# The script uses git describe plus a few other git commands to create a |
|||
# version strings in the following format: |
|||
# |
|||
# X.Y[-Z-gN][-dirty] |
|||
# |
|||
# where X is the major release, Y is the minor release, Z is the number |
|||
# of commits since the X.Y release, N is an eight digit abbreviated SHA |
|||
# hash of the most recent commit and the dirty suffix is appended when |
|||
# the working directory used to create the installation or distribution |
|||
# is not a pristine checkout. Here are some example version strings: |
|||
# |
|||
# 0.0 : initial import |
|||
# 0.0-3-g99ef6933 : 3rd commit since initial import (N=99ef6933) |
|||
# 1.0 : release 1.0 |
|||
# 1.1-12-g3487ab12 : 12th commit since release 1.1 (N=3487ab12) |
|||
# 1.1-12-g3487ab12-dirty : 12th commit since release 1.1 (N=3487ab12) |
|||
# |
|||
# The last example is from a dirty working directory. To find the last |
|||
# release, the script looks for the last tag (does not need to be an |
|||
# annotated tag, but probably should be) which matches the format rel-*. |
|||
# If there is no such tag in the history, then the script uses 0.0 as |
|||
# the release number and counts the total number of commits since the |
|||
# original import for the commit count. |
|||
# |
|||
# If the current directory is not within the working directory, then the |
|||
# path to the source directory should be supplied on the command line. |
|||
# |
|||
# Author : Christopher Batten |
|||
# Date : August 5, 2009 |
|||
|
|||
set -e |
|||
|
|||
#------------------------------------------------------------------------- |
|||
# Command line parsing |
|||
#------------------------------------------------------------------------- |
|||
|
|||
if ( test "$1" = "-h" ); then |
|||
echo "" |
|||
sed -n '3p' $0 | sed -e 's/#//' |
|||
sed -n '5,/^$/p' $0 | sed -e 's/#//' |
|||
exit 1 |
|||
fi |
|||
|
|||
# Source directory command line option |
|||
|
|||
src_dir="." |
|||
if ( test -n "$1" ); then |
|||
src_dir="$1" |
|||
fi |
|||
|
|||
#------------------------------------------------------------------------- |
|||
# Verify source directory |
|||
#------------------------------------------------------------------------- |
|||
# If the source directory is not a git working directory output a |
|||
# question mark. A distribution will not be in a working directory, but |
|||
# the build system should be structured such that this script is not |
|||
# executed (and instead the version information should probably come |
|||
# from configure). If the user does not specify a source directory use |
|||
# the current directory. |
|||
|
|||
if !( git rev-parse --is-inside-work-tree &> /dev/null ); then |
|||
echo "?" |
|||
exit 1; |
|||
fi |
|||
|
|||
top_dir=`git rev-parse --show-cdup` |
|||
cd ./${top_dir} |
|||
|
|||
#------------------------------------------------------------------------- |
|||
# Create the version string |
|||
#------------------------------------------------------------------------- |
|||
# See if we can do a describe based on a tag and if not use a default |
|||
# release number of 0.0 so that we always get canonical version number |
|||
|
|||
if ( git describe --tags --match "rel-*" &> /dev/null ); then |
|||
ver_str=`git describe --tags --match "rel-*" | sed 's/rel-//'` |
|||
else |
|||
ver_num="0.0" |
|||
ver_commits=`git rev-list --all | wc -l | tr -d " "` |
|||
ver_sha=`git describe --tags --match "rel-*" --always` |
|||
ver_str="${ver_num}-${ver_commits}-g${ver_sha}" |
|||
fi |
|||
|
|||
# Add a dirty suffix if working directory is dirty |
|||
|
|||
if !( git diff --quiet ); then |
|||
ver_str="${ver_str}-dirty" |
|||
else |
|||
untracked=`git ls-files --directory --exclude-standard --others -t` |
|||
if ( test -n "${untracked}" ); then |
|||
ver_str="${ver_str}-dirty" |
|||
fi |
|||
fi |
|||
|
|||
# Output the final version string |
|||
|
|||
echo "${ver_str}" |
|||
|
|||
# Final exit status |
|||
|
|||
exit 0; |
|||
|
|||
Loading…
Reference in new issue