diff options
author | Boris Kolpackov <boris@codesynthesis.com> | 2010-02-05 18:01:45 +0200 |
---|---|---|
committer | Boris Kolpackov <boris@codesynthesis.com> | 2010-02-05 18:01:45 +0200 |
commit | d7b7e218bfe92516f525568a6c1c9e1a9eb241fe (patch) | |
tree | 6cbc3155d7188f65e4b806c6edeecdd53393da69 |
Start tracking build with git
158 files changed, 10906 insertions, 0 deletions
@@ -0,0 +1,34 @@ +Prerequisites + + - GNU make >= 3.81 http://www.gnu.org/software/make/ + - GNU bash >= 2.05a http://www.gnu.org/software/bash/ + + +Installing the build system + + To install the build system you can say + + $ make install + + in the root directory of the source distribution. If you want to + install it to a different location (default is /usr/local) you + can say + + $ make install_prefix=/usr install + + Note that you need to install the build runtime into a place where + `make' will look by default (normally /usr/include and /usr/local/include). + Alternatively, you can install it into some other place (e.g., your home + directory) and set MAKEFLAGS accordingly: + + $ make install install_prefix=/home/boris/local + $ export MAKEFLAGS="-I /home/boris/local/include" + + +Building examples + + There is a makefile accompanying each example. Saying 'make' + usually does the trick. Note that saying 'make install' in + example directory will install what the example has built as + opposed to installing the example itself. + @@ -0,0 +1,340 @@ + GNU GENERAL PUBLIC LICENSE + Version 2, June 1991 + + Copyright (C) 1989, 1991 Free Software Foundation, Inc. + 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + Preamble + + The licenses for most software are designed to take away your +freedom to share and change it. By contrast, the GNU General Public +License is intended to guarantee your freedom to share and change free +software--to make sure the software is free for all its users. This +General Public License applies to most of the Free Software +Foundation's software and to any other program whose authors commit to +using it. (Some other Free Software Foundation software is covered by +the GNU Library General Public License instead.) You can apply it to +your programs, too. + + When we speak of free software, we are referring to freedom, not +price. Our General Public Licenses are designed to make sure that you +have the freedom to distribute copies of free software (and charge for +this service if you wish), that you receive source code or can get it +if you want it, that you can change the software or use pieces of it +in new free programs; and that you know you can do these things. + + To protect your rights, we need to make restrictions that forbid +anyone to deny you these rights or to ask you to surrender the rights. +These restrictions translate to certain responsibilities for you if you +distribute copies of the software, or if you modify it. + + For example, if you distribute copies of such a program, whether +gratis or for a fee, you must give the recipients all the rights that +you have. You must make sure that they, too, receive or can get the +source code. And you must show them these terms so they know their +rights. + + We protect your rights with two steps: (1) copyright the software, and +(2) offer you this license which gives you legal permission to copy, +distribute and/or modify the software. + + Also, for each author's protection and ours, we want to make certain +that everyone understands that there is no warranty for this free +software. If the software is modified by someone else and passed on, we +want its recipients to know that what they have is not the original, so +that any problems introduced by others will not reflect on the original +authors' reputations. + + Finally, any free program is threatened constantly by software +patents. We wish to avoid the danger that redistributors of a free +program will individually obtain patent licenses, in effect making the +program proprietary. To prevent this, we have made it clear that any +patent must be licensed for everyone's free use or not licensed at all. + + The precise terms and conditions for copying, distribution and +modification follow. + + GNU GENERAL PUBLIC LICENSE + TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION + + 0. This License applies to any program or other work which contains +a notice placed by the copyright holder saying it may be distributed +under the terms of this General Public License. The "Program", below, +refers to any such program or work, and a "work based on the Program" +means either the Program or any derivative work under copyright law: +that is to say, a work containing the Program or a portion of it, +either verbatim or with modifications and/or translated into another +language. (Hereinafter, translation is included without limitation in +the term "modification".) Each licensee is addressed as "you". + +Activities other than copying, distribution and modification are not +covered by this License; they are outside its scope. The act of +running the Program is not restricted, and the output from the Program +is covered only if its contents constitute a work based on the +Program (independent of having been made by running the Program). +Whether that is true depends on what the Program does. + + 1. You may copy and distribute verbatim copies of the Program's +source code as you receive it, in any medium, provided that you +conspicuously and appropriately publish on each copy an appropriate +copyright notice and disclaimer of warranty; keep intact all the +notices that refer to this License and to the absence of any warranty; +and give any other recipients of the Program a copy of this License +along with the Program. + +You may charge a fee for the physical act of transferring a copy, and +you may at your option offer warranty protection in exchange for a fee. + + 2. You may modify your copy or copies of the Program or any portion +of it, thus forming a work based on the Program, and copy and +distribute such modifications or work under the terms of Section 1 +above, provided that you also meet all of these conditions: + + a) You must cause the modified files to carry prominent notices + stating that you changed the files and the date of any change. + + b) You must cause any work that you distribute or publish, that in + whole or in part contains or is derived from the Program or any + part thereof, to be licensed as a whole at no charge to all third + parties under the terms of this License. + + c) If the modified program normally reads commands interactively + when run, you must cause it, when started running for such + interactive use in the most ordinary way, to print or display an + announcement including an appropriate copyright notice and a + notice that there is no warranty (or else, saying that you provide + a warranty) and that users may redistribute the program under + these conditions, and telling the user how to view a copy of this + License. (Exception: if the Program itself is interactive but + does not normally print such an announcement, your work based on + the Program is not required to print an announcement.) + +These requirements apply to the modified work as a whole. If +identifiable sections of that work are not derived from the Program, +and can be reasonably considered independent and separate works in +themselves, then this License, and its terms, do not apply to those +sections when you distribute them as separate works. But when you +distribute the same sections as part of a whole which is a work based +on the Program, the distribution of the whole must be on the terms of +this License, whose permissions for other licensees extend to the +entire whole, and thus to each and every part regardless of who wrote it. + +Thus, it is not the intent of this section to claim rights or contest +your rights to work written entirely by you; rather, the intent is to +exercise the right to control the distribution of derivative or +collective works based on the Program. + +In addition, mere aggregation of another work not based on the Program +with the Program (or with a work based on the Program) on a volume of +a storage or distribution medium does not bring the other work under +the scope of this License. + + 3. You may copy and distribute the Program (or a work based on it, +under Section 2) in object code or executable form under the terms of +Sections 1 and 2 above provided that you also do one of the following: + + a) Accompany it with the complete corresponding machine-readable + source code, which must be distributed under the terms of Sections + 1 and 2 above on a medium customarily used for software interchange; or, + + b) Accompany it with a written offer, valid for at least three + years, to give any third party, for a charge no more than your + cost of physically performing source distribution, a complete + machine-readable copy of the corresponding source code, to be + distributed under the terms of Sections 1 and 2 above on a medium + customarily used for software interchange; or, + + c) Accompany it with the information you received as to the offer + to distribute corresponding source code. (This alternative is + allowed only for noncommercial distribution and only if you + received the program in object code or executable form with such + an offer, in accord with Subsection b above.) + +The source code for a work means the preferred form of the work for +making modifications to it. For an executable work, complete source +code means all the source code for all modules it contains, plus any +associated interface definition files, plus the scripts used to +control compilation and installation of the executable. However, as a +special exception, the source code distributed need not include +anything that is normally distributed (in either source or binary +form) with the major components (compiler, kernel, and so on) of the +operating system on which the executable runs, unless that component +itself accompanies the executable. + +If distribution of executable or object code is made by offering +access to copy from a designated place, then offering equivalent +access to copy the source code from the same place counts as +distribution of the source code, even though third parties are not +compelled to copy the source along with the object code. + + 4. You may not copy, modify, sublicense, or distribute the Program +except as expressly provided under this License. Any attempt +otherwise to copy, modify, sublicense or distribute the Program is +void, and will automatically terminate your rights under this License. +However, parties who have received copies, or rights, from you under +this License will not have their licenses terminated so long as such +parties remain in full compliance. + + 5. You are not required to accept this License, since you have not +signed it. However, nothing else grants you permission to modify or +distribute the Program or its derivative works. These actions are +prohibited by law if you do not accept this License. Therefore, by +modifying or distributing the Program (or any work based on the +Program), you indicate your acceptance of this License to do so, and +all its terms and conditions for copying, distributing or modifying +the Program or works based on it. + + 6. Each time you redistribute the Program (or any work based on the +Program), the recipient automatically receives a license from the +original licensor to copy, distribute or modify the Program subject to +these terms and conditions. You may not impose any further +restrictions on the recipients' exercise of the rights granted herein. +You are not responsible for enforcing compliance by third parties to +this License. + + 7. If, as a consequence of a court judgment or allegation of patent +infringement or for any other reason (not limited to patent issues), +conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot +distribute so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you +may not distribute the Program at all. For example, if a patent +license would not permit royalty-free redistribution of the Program by +all those who receive copies directly or indirectly through you, then +the only way you could satisfy both it and this License would be to +refrain entirely from distribution of the Program. + +If any portion of this section is held invalid or unenforceable under +any particular circumstance, the balance of the section is intended to +apply and the section as a whole is intended to apply in other +circumstances. + +It is not the purpose of this section to induce you to infringe any +patents or other property right claims or to contest validity of any +such claims; this section has the sole purpose of protecting the +integrity of the free software distribution system, which is +implemented by public license practices. Many people have made +generous contributions to the wide range of software distributed +through that system in reliance on consistent application of that +system; it is up to the author/donor to decide if he or she is willing +to distribute software through any other system and a licensee cannot +impose that choice. + +This section is intended to make thoroughly clear what is believed to +be a consequence of the rest of this License. + + 8. If the distribution and/or use of the Program is restricted in +certain countries either by patents or by copyrighted interfaces, the +original copyright holder who places the Program under this License +may add an explicit geographical distribution limitation excluding +those countries, so that distribution is permitted only in or among +countries not thus excluded. In such case, this License incorporates +the limitation as if written in the body of this License. + + 9. The Free Software Foundation may publish revised and/or new versions +of the General Public License from time to time. Such new versions will +be similar in spirit to the present version, but may differ in detail to +address new problems or concerns. + +Each version is given a distinguishing version number. If the Program +specifies a version number of this License which applies to it and "any +later version", you have the option of following the terms and conditions +either of that version or of any later version published by the Free +Software Foundation. If the Program does not specify a version number of +this License, you may choose any version ever published by the Free Software +Foundation. + + 10. If you wish to incorporate parts of the Program into other free +programs whose distribution conditions are different, write to the author +to ask for permission. For software which is copyrighted by the Free +Software Foundation, write to the Free Software Foundation; we sometimes +make exceptions for this. Our decision will be guided by the two goals +of preserving the free status of all derivatives of our free software and +of promoting the sharing and reuse of software generally. + + NO WARRANTY + + 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY +FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN +OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES +PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED +OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF +MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS +TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE +PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, +REPAIR OR CORRECTION. + + 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING +WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR +REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, +INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING +OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED +TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY +YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER +PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE +POSSIBILITY OF SUCH DAMAGES. + + END OF TERMS AND CONDITIONS + + How to Apply These Terms to Your New Programs + + If you develop a new program, and you want it to be of the greatest +possible use to the public, the best way to achieve this is to make it +free software which everyone can redistribute and change under these terms. + + To do so, attach the following notices to the program. It is safest +to attach them to the start of each source file to most effectively +convey the exclusion of warranty; and each file should have at least +the "copyright" line and a pointer to where the full notice is found. + + <one line to give the program's name and a brief idea of what it does.> + Copyright (C) <year> <name of author> + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + + +Also add information on how to contact you by electronic and paper mail. + +If the program is interactive, make it output a short notice like this +when it starts in an interactive mode: + + Gnomovision version 69, Copyright (C) year name of author + Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. + This is free software, and you are welcome to redistribute it + under certain conditions; type `show c' for details. + +The hypothetical commands `show w' and `show c' should show the appropriate +parts of the General Public License. Of course, the commands you use may +be called something other than `show w' and `show c'; they could even be +mouse-clicks or menu items--whatever suits your program. + +You should also get your employer (if you work as a programmer) or your +school, if any, to sign a "copyright disclaimer" for the program, if +necessary. Here is a sample; alter the names: + + Yoyodyne, Inc., hereby disclaims all copyright interest in the program + `Gnomovision' (which makes passes at compilers) written by James Hacker. + + <signature of Ty Coon>, 1 April 1989 + Ty Coon, President of Vice + +This General Public License does not permit incorporating your program into +proprietary programs. If your program is a subroutine library, you may +consider it more useful to permit linking proprietary applications with the +library. If this is what you want to do, use the GNU Library General +Public License instead of this License. @@ -0,0 +1,145 @@ +Version 0.3.6 + + * Search for shared libraries before static. + +Version 0.3.5 + + * New subsystem, ld, that is used by both c and cxx subsystems. + + * Support for generic C and C++ compilers. + + * Follow symlinks in the install-dir function. + + * Various optimizations, including for the upcoming GNU make 3.82. + + * Updated config.guess and config.sub. + +Version 0.3.4 + + * C compilation subsystem. Supported compilers are GNU gcc and Intel icc. + + * Git .gitignore generation subsystem. + + * Fallback install-sh installation script. + + * Reworked sed scripts not to use GNU extensions. + +Version 0.3.3 + + * Fix a bug in C++ dependency processing sed script. + +Version 0.3.2 + + * Add read_value to build/dialog.bash + + * Fix problem with potentially installed generated header files and + automatic dependency extraction. While at it, factored out dependency + post-processing into a separate script. + +Version 0.3.1 + + * Minor changes to the xargs and sed usage to make it not rely + on non-POSIX features. + +Version 0.3.0 + + * Format of the library file (.l) has changed to include rpath + properties. + + * Adding dynamic library paths (via rpath) is now optional. + + * Paths from extra ld options are now extracted and propagated + to make (via vpath). + +Version 0.2.2 + + * Configuration scripts now ask for ar and ranlib if static library + is selected. This is mainly useful for cross-compilation. + + * The C++ configuration script now ask for extra preprocessor, compiler, + and linker options as well as extra libraries to link with. There + are also corresponding command-line variables, cxx_pp_options, + cxx_options, cxx_ld_options, and cxx_libs, that, if set, the script + will silently use instead of asking. + +Version 0.2.1 + + * Build/host/target system detection is now in the system.make file and + not automatically included by bootstrap.make. The host_system and + target_system make variables should be used to set host and target + systems during configuration. + + * The include.make file was moved one level up from install directory. + +Version 0.2.0 + + * This release is backwards-incompatible with the 0.1 series. + + * Unified load and import facilities. Now import requires full file name. + + * A target from an imported makefile cannot become the default target. + + * Frame facility now restores all variables and preservs their flavor. + + * New unified clean suffix scheme: <.out><.src>.clean, e.g., + + %.o: %.cxx -> %.o.cxx.clean: + %: %.o -> %.o.clean: + %: %.m4 -> %.m4.clean: + + * Got rid of the .e suffix in the executable building rules. + +Version 0.1.15 + + * Experimental cxx_ld_options make command-line variable is now + recognized and saved during the configuration stage. + + * Import mechanism now uses unconditional include instead of + include-once. + + * New installation variables (doc, man, info) were added to + build/install/configuration.make. + +Version 0.1.14 + + * New translator: m4. + + * New C/C++ automatic dependency generation mechanism with support for + generated header files. + + +Version 0.1.13 + + * Requires GNU make 3.81beta3 or later. + + * Integrated config.guess & config.sub scripts for host/build configuration + guessing. + + +Version 0.1.12 + + * Requires -bk5-patched GNU make. + + * Multiple optimizations. + + * Preprocessor options are now explicitly propagated through import/export + calls instead of order-only prerequisites. + + * Compiler library search paths are extracted and propagated to make. This + ensures that `-lfoo' means the same no matter where it appears - in make + rule or compiler command line. + + * Common shell dialog code has been factored out to build/dialog.bash and + also made more robust with regards to wrong input and various path + formats (e.g., both relative paths handling and tilde expansion are now + supported). + + * Include function family now accepts lists of names. + + * Many important variables including `*_root', `*_base' and `project_name' + are now exported by default (and thus available in configure scripts). + + +Version 0.1.11 + + * Released to public. @@ -0,0 +1,41 @@ +build is a software build system implemented on top of GNU make. In +particular, build + + * is not a make replacement + * is not written in Java + * does not use XML + +build was designed with the following tasks in mind: + + * configuration + * building + * testing + * installation + +Some of its features include: + + * position-independent makefiles + + * non-recursive multi-makefile include-based structure + + * leaf makefiles are full-fledged GNU makefiles, not just variable + definitions + + * complete dependency graph + + * inter-project dependency tracking + + * extensible translator framework + + +See the NEWS file for the user-visible changes from the previous release. + +See the LICENSE file for distribution conditions. + +See the INSTALL file for prerequisites and installation instructions. + +See the documentation/index.xhtml file for documentation. + +The project page is at http://www.codesynthesis.com/projects/build/. + +Send bug reports or any other feedback to build-users@codesynthesis.com. diff --git a/build/abspath.make b/build/abspath.make new file mode 100644 index 0000000..428608c --- /dev/null +++ b/build/abspath.make @@ -0,0 +1,19 @@ +# file : build/abspath.make +# author : Boris Kolpackov <boris@codesynthesis.com> +# copyright : Copyright (c) 2004-2010 Code Synthesis Tools CC +# license : GNU GPL v2; see accompanying LICENSE file + +.PHONY: FORCE + +%:: FORCE + @echo $(abspath $@) + +$(MAKEFILE_LIST):: ;@: + +# Remove all default rules. +# +.SUFFIXES: + +ifeq ($(filter -r,$(MAKEFLAGS)),) +MAKEFLAGS += -r +endif diff --git a/build/bootstrap.make b/build/bootstrap.make new file mode 100644 index 0000000..c45f952 --- /dev/null +++ b/build/bootstrap.make @@ -0,0 +1,341 @@ +# file : build/bootstrap.make +# author : Boris Kolpackov <boris@codesynthesis.com> +# copyright : Copyright (c) 2004-2010 Code Synthesis Tools CC +# license : GNU GPL v2; see accompanying LICENSE file + + + +# First time bootstrap.make is read +# +ifndef %makefile% + +# Configure make. +# + +# Forces make to delete targets whos rebuild commands failed but +# updated the target. +# +.DELETE_ON_ERROR: + +# Remove all built-in rules. +# +.SUFFIXES: + +ifeq ($(filter -r,$(MAKEFLAGS)),) +MAKEFLAGS += -r +endif + + +# Disable implicit phony misfeature. +# +#ifeq ($(filter --no-implicit-phony,$(MAKEFLAGS)),) +#MAKEFLAGS += --no-implicit-phony +#endif + +# Enable second expansion. +# +.SECONDEXPANSION: + +# Force target. Used to force rule executions. +# +.PHONY: FORCE + + +# Export variables that could be useful for configuration scripts. +# +export bld_root +export MAKE + +%replica% := +%foreign% := +%interactive% := t + +# List of realpath'ed include-once files. +# +%included_files% := + +#$(warning init %included_files%: $(%included_files%)) + +# @@ maybe I should set makefile to bootstrap and restore it at the end. +# This way I will be able to use %makefile% below (instead of _self) and +# also it will be consistent. +# + +%makefile% := $(abspath $(firstword $(MAKEFILE_LIST))) +%makefile_realpath% := $(realpath $(%makefile%)) + + +# +# include facility +# + +# Execute makefile search algorithm. Return abspath of the makefile if found +# and empty string otherwise. +# +%frame_exclude% += include-find-makefile +define include-find-makefile +$(if $(wildcard $1),\ +$(abspath $1),\ +$(if $(filter-out /%,$1),\ +$(call include-search-dirs,$1,$(.INCLUDE_DIRS)))) +endef + +# Search for $1 in the list of directoris $2 +# +%frame_exclude% += include-search-dirs +define include-search-dirs +$(if $(strip $2),\ +$(if $(wildcard $(firstword $2)/$1),\ +$(abspath $(firstword $2)/$1),\ +$(call include-search-dirs,$1,$(wordlist 2,$(words $2),$2)))) +endef + +# Test if $1 is a 'foreign' makefile, i.e., does not reside in +# src_root, out_root, or bld_root. +# +%frame_exclude% += include-test-foreign +define include-test-foreign +$(if $(%foreign%),t,\ +$(if $(filter $(bld_root)/% $(src_root)/% $(out_root)/%,$1),,t)) +endef + + +%frame_exclude% += include-body +define include-body +%interactive% := +%makefile% := $(call include-find-makefile,$2) +%makefile_realpath% := $(realpath $(%makefile%)) +%foreign% := $(call include-test-foreign,$(%makefile%)) + +$1 $$(if $$(%makefile%),$$(%makefile%),$2) + +%makefile_realpath% := $3 +%makefile% := $4 +%interactive% := $5 +%foreign% := $6 +endef + +%frame_exclude% += include +define include +$(eval $(foreach f,$1,\ + $(call include-body,\ + include,$f,$(%makefile_realpath%),$(%makefile%),$(%interactive%),$(%foreign%)))) +endef + +%frame_exclude% += -include +define -include +$(eval $(foreach f,$1,\ + $(call include-body,\ + -include,$f,$(%makefile_realpath%),$(%makefile%),$(%interactive%),$(%foreign%)))) +endef + + +# +# include-once +# + +# This one simply delegates to the include directive to get the +# error message. +# +# $1 : include/-include +# $2 : file +# +%frame_exclude% += include-once-failed-body +define include-once-failed-body +$1 $2 +endef + +# +# $1 : include/-include +# $2 : file +# +%frame_exclude% += include-once-file-body +define include-once-file-body +%interactive% := +%makefile% := $2 +%makefile_realpath% := $(realpath $2) +%foreign% := $(call include-test-foreign,$(%makefile%)) + +%included_files% += $$(%makefile_realpath%) + +$1 $2 + +%makefile_realpath% := $3 +%makefile% := $4 +%interactive% := $5 +%foreign% := $6 +endef + + +%frame_exclude% += include-once-file-filter +define include-once-file-filter +$(if $(filter $(realpath $2),$(%included_files%)),,\ + $(call include-once-file-body,\ + $1,$2,$(%makefile_realpath%),$(%makefile%),$(%interactive%),$(%foreign%))) +endef + +# +# $1 : include/-include +# $2 : file +# $6 : value +# + +%frame_exclude% += include-once-value-body +define include-once-value-body +%interactive% := +%makefile% := $2 +%makefile_realpath% := $(realpath $2) +%foreign% := $(call include-test-foreign,$(%makefile%)) + +%include_once_$$(%makefile_realpath%)% += $7 + +$1 $2 + +%makefile_realpath% := $3 +%makefile% := $4 +%interactive% := $5 +%foreign% := $6 +endef + + +%frame_exclude% += include-once-value-filter +define include-once-value-filter +$(if $(filter $3,$(value %include_once_$(realpath $2)%)),,\ + $(call include-once-value-body,\ + $1,$2,$(%makefile_realpath%),$(%makefile%),$(%interactive%),$(%foreign%),$3)) +endef + + +# $1 - include/-include +# $2 - abspath or empty if not found +# $3 - orginal path +# $4 - value [optional] +# +%frame_exclude% += include-once-filter +define include-once-filter +$(if $2,\ +$(if $4,\ +$(call include-once-value-filter,$1,$2,$4),\ +$(call include-once-file-filter,$1,$2)),\ +$(call include-once-failed-body,$1,$3)) +endef + +%frame_exclude% += include-once +define include-once +$(eval $(call include-once-filter,\ +include,$(call include-find-makefile,$1),$1,$(strip $2))) +endef + +%frame_exclude% += -include-once +define -include-once +$(eval $(call include-once-filter,\ +-include,$(call include-find-makefile,$1),$1,$(strip $2))) +endef + + +#$(warning include facility is up) + +endif # %makefile% + +# +# +bld_root := $(abspath $(dir $(lastword $(MAKEFILE_LIST)))) + + +# initialize {src,out}_{root,base} +# +%frame_exclude% += find-bootstrap-base +define find-bootstrap-base +$(if $(findstring $(abspath $(lastword $1)),$(%makefile%)),$2,\ +$(call find-bootstrap-base,\ +$(wordlist 1,$(words $(wordlist 2,$(words $1),$1)),$1),\ +$(lastword $1))) +endef + +src_root := $(abspath $(dir $(call find-bootstrap-base,$(MAKEFILE_LIST)))..) +src_base := $(abspath $(dir $(%makefile%))) + +ifneq ($(src_root),$(src_base)) + +ifeq ($(origin out_root),undefined) + out_root := $(abspath $(patsubst \ + %$(subst $(src_root)/,,$(src_base)),%,$(CURDIR))) +endif + +out_base := $(out_root)/$(subst $(src_root)/,,$(src_base)) + +else + +ifeq ($(origin out_root),undefined) + out_root := $(abspath $(CURDIR)) +endif + +out_base := $(out_root) + +endif + +scf_root := $(src_root)/build +dcf_root := $(out_root)/build + +$(out_root)/%: export out_root := $(out_root) +$(out_root)/%: export src_root := $(src_root) +$(out_root)/%: export scf_root := $(scf_root) +$(out_root)/%: export dcf_root := $(dcf_root) +$(out_root)/%: export project_name := $(project_name) + +$(out_base)/%: out_root := $(out_root) +$(out_base)/%: out_base := $(out_base) +$(out_base)/%: src_base := $(src_base) + +ifdef build_debug + +$(warning "bld root: $(bld_root)") +$(warning "scf root: $(scf_root)") +$(warning "dcf root: $(dcf_root)") +$(warning "src root: $(src_root)") +$(warning "src base: $(src_base)") +$(warning "out root: $(out_root)") +$(warning "out base: $(out_base)") + +endif + +#$(warning paths are set) + +# frame facility +# +$(call include-once,$(bld_root)/frame.make) + +# import facility +# +$(call include-once,$(bld_root)/import.make) + +# Load some common facilities. +# +$(call include-once,$(bld_root)/literals.make) +$(call include-once,$(bld_root)/message.make) +$(call include-once,$(bld_root)/dir.make) + + +# Static configuration. +# +$(call include,$(bld_root)/configuration-static.make) + +ifneq ($(bld_root),$(scf_root)) +$(call -include,$(scf_root)/configuration-static.make) +endif + + +# `disfigure' target. +# +.PHONY: disfigure + +disfigure:: $(build_absolute_clean_target) + +#@@ Is there a better way? +# +ifeq ($(.DEFAULT_GOAL),disfigure) +.DEFAULT_GOAL := +endif + +# Dynamic configuration. +# diff --git a/build/c/c-d.make b/build/c/c-d.make new file mode 100644 index 0000000..446d643 --- /dev/null +++ b/build/c/c-d.make @@ -0,0 +1,10 @@ +# file : build/c/c-d.make +# author : Boris Kolpackov <boris@codesynthesis.com> +# copyright : Copyright (c) 2004-2010 Code Synthesis Tools CC +# license : GNU GPL v2; see accompanying LICENSE file + +$(call include,$(bld_root)/c/configuration.make) + +ifdef c_id +$(call include-once,$(bld_root)/c/$(c_id)/c-d.make,$(out_base)) +endif diff --git a/build/c/c-o.make b/build/c/c-o.make new file mode 100644 index 0000000..0e6a532 --- /dev/null +++ b/build/c/c-o.make @@ -0,0 +1,11 @@ +# file : build/c/c-o.make +# author : Boris Kolpackov <boris@codesynthesis.com> +# copyright : Copyright (c) 2004-2010 Code Synthesis Tools CC +# license : GNU GPL v2; see accompanying LICENSE file + +$(call include,$(bld_root)/c/configuration.make) + + +ifdef c_id +$(call include-once,$(bld_root)/c/$(c_id)/c-o.make,$(out_base)) +endif diff --git a/build/c/configuration-rules.make b/build/c/configuration-rules.make new file mode 100644 index 0000000..836fa1d --- /dev/null +++ b/build/c/configuration-rules.make @@ -0,0 +1,19 @@ +# file : build/c/configuration-rules.make +# author : Boris Kolpackov <boris@codesynthesis.com> +# copyright : Copyright (c) 2004-2010 Code Synthesis Tools CC +# license : GNU GPL v2; see accompanying LICENSE file + +$(dcf_root)/c/configuration-dynamic.make: | $(dcf_root)/c/. + $(call message,,$(bld_root)/c/configure $@ \ +"$(origin c_pp_options)" \ +"$(origin c_options)" \ +"$(origin c_ld_options)" \ +"$(origin c_libs)") + +ifndef %foreign% + +disfigure:: + $(call message,rm $(dcf_root)/c/configuration-dynamic.make,\ +rm -f $(dcf_root)/c/configuration-dynamic.make) + +endif diff --git a/build/c/configuration-static.make b/build/c/configuration-static.make new file mode 100644 index 0000000..d95ebfa --- /dev/null +++ b/build/c/configuration-static.make @@ -0,0 +1,13 @@ +# file : build/c/configuration-static.make +# author : Boris Kolpackov <boris@codesynthesis.com> +# copyright : Copyright (c) 2004-2010 Code Synthesis Tools CC +# license : GNU GPL v2; see accompanying LICENSE file + +c_h_suffix := h +c_s_suffix := c + +# Get user-supplied static configuration if any. +# +ifneq ($(bld_root),$(scf_root)) +$(call -include,$(scf_root)/c/configuration-static.make) +endif diff --git a/build/c/configuration.make b/build/c/configuration.make new file mode 100644 index 0000000..97da2f0 --- /dev/null +++ b/build/c/configuration.make @@ -0,0 +1,44 @@ +# file : build/c/configuration.make +# author : Boris Kolpackov <boris@codesynthesis.com> +# copyright : Copyright (c) 2004-2010 Code Synthesis Tools CC +# license : GNU GPL v2; see accompanying LICENSE file + +$(call include-once,$(bld_root)/c/configuration-rules.make,$(dcf_root)) + +# Static configuration. +# +$(call include,$(bld_root)/c/configuration-static.make) + +# Dynamic configuration. +# +c_id := +c_optimize := +c_debug := +c_rpath := + +c_pp_extra_options := +c_extra_options := +c_ld_extra_options := +c_extra_libs := +c_extra_lib_paths := + +$(call -include,$(dcf_root)/c/configuration-dynamic.make) + +ifdef c_id + +$(out_root)/%: c_id := $(c_id) +$(out_root)/%: c_optimize := $(c_optimize) +$(out_root)/%: c_debug := $(c_debug) +$(out_root)/%: c_rpath := $(c_rpath) + +$(out_root)/%: c_pp_extra_options := $(c_pp_extra_options) +$(out_root)/%: c_extra_options := $(c_extra_options) +$(out_root)/%: c_ld_extra_options := $(c_ld_extra_options) +$(out_root)/%: c_extra_libs := $(c_extra_libs) +$(out_root)/%: c_extra_lib_paths := $(c_extra_lib_paths) + +else + +.NOTPARALLEL: + +endif diff --git a/build/c/configure b/build/c/configure new file mode 100755 index 0000000..6281fa2 --- /dev/null +++ b/build/c/configure @@ -0,0 +1,166 @@ +#! /usr/bin/env bash + +# file : build/c/configure +# author : Boris Kolpackov <boris@codesynthesis.com> +# copyright : Copyright (c) 2004-2010 Code Synthesis Tools CC +# license : GNU GPL v2; see accompanying LICENSE file + +# $1 out file +# $2 origin of the c_pp_options make variable +# $3 origin of the c_options make variable +# $4 origin of the c_ld_options make variable +# $5 origin of the c_libs make variable +# +# bld_root - build root +# project_name - project name +# + +source $bld_root/dialog.bash + +$echo +$echo +$echo "configuring '$project_name'" +$echo +$echo + +$echo +$echo "Please select the C compiler you would like to use:" +$echo +$echo "(1) GNU C (gcc)" +$echo "(2) Intel C (icc)" +$echo "(3) Other C compiler" +$echo + +id=`read_option "gnu intel generic" "gnu"` + +if [ "$id" != "generic" ]; then + + $echo + $echo "Would you like the C compiler to optimize generated code?" + $echo + + optimize=`read_y_n y` + + + $echo + $echo "Would you like the C compiler to generate debug information?" + $echo + + debug=`read_y_n y` + + $echo + $echo "Embed dynamic library paths into executables (rpath)?" + $echo + + rpath=`read_y_n y` + +fi + +# pp_options +# +if [ "$2" != "undefined" ]; then + + pp_options=$c_pp_options + + if [ "$pp_options" ]; then + $echo + $echo "Extra C preprocessor options: $pp_options" + $echo + fi +else + + $echo + $echo "Please enter any extra C preprocessor options." + $echo + + read -e -p "[]: " pp_options +fi + + +# options +# +if [ "$3" != "undefined" ]; then + + options=$c_options + + if [ "$options" ]; then + $echo + $echo "Extra C compiler options: $options" + $echo + fi +else + + $echo + $echo "Please enter any extra C compiler options." + $echo + + read -p "[]: " options +fi + + +# ld_options +# +if [ "$4" != "undefined" ]; then + + ld_options=$c_ld_options + + if [ "$ld_options" ]; then + $echo + $echo "Extra C linker options: $ld_options" + $echo + fi +else + + $echo + $echo "Please enter any extra C linker options." + $echo + + read -e -p "[]: " ld_options +fi + + +# libs +# +if [ "$5" != "undefined" ]; then + + libs=$c_libs + + if [ "$libs" ]; then + $echo + $echo "Extra C libraries: $libs" + $echo + fi +else + + $echo + $echo "Please enter any extra C libraries." + $echo + + read -e -p "[]: " libs +fi + + +# Extract -L paths from the ld options. +# +paths= + +if [ "$ld_options" ]; then + paths=`echo "$ld_options" | sed -e 's/-L *\([^ ]*\)/\\ +-L\1\\ +/g' | sed -e 's/^-L\([^ ]*\)$/\1/' -e t -e d` + paths=`echo $paths | sed -e 's/ /:/g'` +fi + +echo "c_id := $id" >$1 + +if [ "$id" != "generic" ]; then + echo "c_optimize := $optimize" >>$1 + echo "c_debug := $debug" >>$1 + echo "c_rpath := $rpath" >>$1 +fi + +echo "c_pp_extra_options := $pp_options" >>$1 +echo "c_extra_options := $options" >>$1 +echo "c_ld_extra_options := $ld_options" >>$1 +echo "c_extra_libs := $libs" >>$1 +echo "c_extra_lib_paths := $paths" >>$1 diff --git a/build/c/cpp-options.make b/build/c/cpp-options.make new file mode 100644 index 0000000..8956d41 --- /dev/null +++ b/build/c/cpp-options.make @@ -0,0 +1,36 @@ +# file : build/c/cpp-options.make +# author : Boris Kolpackov <boris@codesynthesis.com> +# copyright : Copyright (c) 2004-2010 Code Synthesis Tools CC +# license : GNU GPL v2; see accompanying LICENSE file + +$(out_base)/%.cpp-options: c-cpp-options-expand-impl = $(if $1,cat $1 >>$2) +$(out_base)/%.cpp-options: c-cpp-options-expand = \ +$(call c-cpp-options-expand-impl,$(filter %.cpp-options,$1),$2) + + +#@@ Asymmetry: I hide creation commands but show removals. +# +$(out_base)/%.cpp-options: c-cpp-options-force-impl = \ +$(if $(subst $1,,$2)$(subst $2,,$1),FORCE) + +$(out_base)/%.cpp-options: c-cpp-options-force = \ +$(call c-cpp-options-force-impl,$(shell if test -f $1; then exec head -n 1 $1; fi),include: $2) + + +# @@ Need to incroporate prefix: into force-check. Then it will probably +# have to be non-optional. +# + +ifeq ($(src_base),$(out_base)) +$(out_base)/%.cpp-options: $$(call c-cpp-options-force,$$@,$$(value)) +else +$(out_base)/%.cpp-options: $$(call c-cpp-options-force,$$@,$$(value)) | $$(dir $$@). +endif + @echo "include: $(value)" >$@ + $(if $(strip $(prefix)),@echo "prefix: $(prefix)" >>$@) + @$(call c-cpp-options-expand,$^,$@) + +# Clean. +# +$(out_base)/%.cpp-options.clean: + $(call message,rm $(basename $@),rm -f $(basename $@)) diff --git a/build/c/generic/c-d.make b/build/c/generic/c-d.make new file mode 100644 index 0000000..8f77d50 --- /dev/null +++ b/build/c/generic/c-d.make @@ -0,0 +1,19 @@ +# file : build/c/generic/c-o.make +# author : Boris Kolpackov <boris@codesynthesis.com> +# copyright : Copyright (c) 2004-2010 Code Synthesis Tools CC +# license : GNU GPL v2; see accompanying LICENSE file + +$(call include,$(bld_root)/c/generic/configuration.make) + +# Make will try to build dependecies (since they are ultimately included +# files) during configuartion phase without c_generic being discovered +# yet. This is also why dependecies should be included with -include. +# +ifdef c_generic + +.PHONY: $(out_base)/%.o.d.$(c_s_suffix).clean + +$(out_base)/%.o.d.$(c_s_suffix).clean: + @: + +endif diff --git a/build/c/generic/c-o.make b/build/c/generic/c-o.make new file mode 100644 index 0000000..7b6e622 --- /dev/null +++ b/build/c/generic/c-o.make @@ -0,0 +1,40 @@ +# file : build/c/generic/c-o.make +# author : Boris Kolpackov <boris@codesynthesis.com> +# copyright : Copyright (c) 2004-2010 Code Synthesis Tools CC +# license : GNU GPL v2; see accompanying LICENSE file + +$(call include-once,$(bld_root)/c/cpp-options.make,$(out_base)) +$(call include,$(bld_root)/c/generic/configuration.make) + +$(out_base)/%.o: c := $(c_generic) + +#@@ wrong prefix +# +$(out_base)/%.o: expand-cpp-options-impl = \ +$(if $1,$(shell sed -e 's%include: \(.*\)%\1%' -e t -e d $1)) + +$(out_base)/%.o: expand-cpp-options = \ +$(call expand-cpp-options-impl,$(filter %.cpp-options,$1)) + +ifeq ($(out_base),$(src_base)) +$(out_base)/%.o: $(src_base)/%.$(c_s_suffix) +else +$(out_base)/%.o: $(src_base)/%.$(c_s_suffix) | $$(dir $$@). +endif + $(call message,c $<,$(c) \ +$(cpp_options) $(call expand-cpp-options,$^) $(c_pp_extra_options) \ +$(c_options) $(c_pic_options) $(c_extra_options) -o $@ -c $<) + +ifneq ($(out_base),$(src_base)) + +$(out_base)/%.o: $(out_base)/%.$(c_s_suffix) | $$(dir $$@). + $(call message,c $<,$(c) \ +$(cpp_options) $(call expand-cpp-options,$^) $(c_pp_extra_options) \ +$(c_options) $(c_pic_options) $(c_extra_options) -o $@ -c $<) + +endif + +.PHONY: $(out_base)/%.o.$(c_s_suffix).clean + +$(out_base)/%.o.$(c_s_suffix).clean: + $(call message,rm $$1,rm -f $$1,$(basename $(basename $@))) diff --git a/build/c/generic/configuration-rules.make b/build/c/generic/configuration-rules.make new file mode 100644 index 0000000..5fa9117 --- /dev/null +++ b/build/c/generic/configuration-rules.make @@ -0,0 +1,15 @@ +# file : build/c/generic/configuration-rules.make +# author : Boris Kolpackov <boris@codesynthesis.com> +# copyright : Copyright (c) 2004-2010 Code Synthesis Tools CC +# license : GNU GPL v2; see accompanying LICENSE file + +$(dcf_root)/c/generic/configuration-dynamic.make: | $(dcf_root)/c/generic/. + $(call message,,$(bld_root)/c/generic/configure $@) + +ifndef %foreign% + +disfigure:: + $(call message,rm $(dcf_root)/c/generic/configuration-dynamic.make,\ +rm -f $(dcf_root)/c/generic/configuration-dynamic.make) + +endif diff --git a/build/c/generic/configuration-sl-rules.make b/build/c/generic/configuration-sl-rules.make new file mode 100644 index 0000000..e685be6 --- /dev/null +++ b/build/c/generic/configuration-sl-rules.make @@ -0,0 +1,15 @@ +# file : build/c/generic/configuration-sl-rules.make +# author : Boris Kolpackov <boris@codesynthesis.com> +# copyright : Copyright (c) 2004-2010 Code Synthesis Tools CC +# license : GNU GPL v2; see accompanying LICENSE file + +$(dcf_root)/c/generic/configuration-sl-dynamic.make: | $(dcf_root)/c/generic/. + $(call message,,$(bld_root)/c/generic/configure-sl $@) + +ifndef %foreign% + +disfigure:: + $(call message,rm $(dcf_root)/c/generic/configuration-sl-dynamic.make,\ +rm -f $(dcf_root)/c/generic/configuration-sl-dynamic.make) + +endif diff --git a/build/c/generic/configuration-sl.make b/build/c/generic/configuration-sl.make new file mode 100644 index 0000000..b3a18a8 --- /dev/null +++ b/build/c/generic/configuration-sl.make @@ -0,0 +1,21 @@ +# file : build/c/generic/configuration-sl.make +# author : Boris Kolpackov <boris@codesynthesis.com> +# copyright : Copyright (c) 2004-2010 Code Synthesis Tools CC +# license : GNU GPL v2; see accompanying LICENSE file + +$(call include-once,$(bld_root)/c/generic/configuration-sl-rules.make,$(dcf_root)) + +# Dynamic configuration. +# +c_generic_pic_option := + +$(call -include,$(dcf_root)/c/generic/configuration-sl-dynamic.make) + +ifdef c_generic_pic_option + +$(out_root)/%: c_generic_pic_option := $(c_generic_pic_option) +$(out_root)/%: c_generic_shared_option := $(c_generic_shared_option) + +else +.NOTPARALLEL: +endif diff --git a/build/c/generic/configuration.make b/build/c/generic/configuration.make new file mode 100644 index 0000000..95e79f8 --- /dev/null +++ b/build/c/generic/configuration.make @@ -0,0 +1,22 @@ +# file : build/c/generic/configuration.make +# author : Boris Kolpackov <boris@codesynthesis.com> +# copyright : Copyright (c) 2004-2010 Code Synthesis Tools CC +# license : GNU GPL v2; see accompanying LICENSE file + +$(call include-once,$(bld_root)/c/generic/configuration-rules.make,$(dcf_root)) + +# Static configuration. +# +ifneq ($(bld_root),$(scf_root)) +$(call -include,$(scf_root)/c/generic/configuration-static.make) +endif + +# Dynamic configuration. +# +c_generic := + +$(call -include,$(dcf_root)/c/generic/configuration-dynamic.make) + +ifndef c_generic +.NOTPARALLEL: +endif diff --git a/build/c/generic/configure b/build/c/generic/configure new file mode 100755 index 0000000..76be8df --- /dev/null +++ b/build/c/generic/configure @@ -0,0 +1,28 @@ +#! /usr/bin/env bash + +# file : build/c/generic/configure +# author : Boris Kolpackov <boris@codesynthesis.com> +# copyright : Copyright (c) 2004-2010 Code Synthesis Tools CC +# license : GNU GPL v2; see accompanying LICENSE file + +# $1 out file +# +# bld_root - build root +# project_name - project name +# + +source $bld_root/dialog.bash + +$echo +$echo +$echo "configuring '$project_name'" +$echo +$echo + +$echo +$echo "Please enter the C compiler executable you would like to use." +$echo + +c_generic=`read_path --command` + +echo "c_generic := $c_generic" > $1 diff --git a/build/c/generic/configure-sl b/build/c/generic/configure-sl new file mode 100755 index 0000000..5500e8b --- /dev/null +++ b/build/c/generic/configure-sl @@ -0,0 +1,37 @@ +#! /usr/bin/env bash + +# file : build/c/generic/configure-sl +# author : Boris Kolpackov <boris@codesynthesis.com> +# copyright : Copyright (c) 2004-2010 Code Synthesis Tools CC +# license : GNU GPL v2; see accompanying LICENSE file + +# $1 out file +# +# bld_root - build root +# project_name - project name +# + +source $bld_root/dialog.bash + +$echo +$echo +$echo "configuring '$project_name'" +$echo +$echo + +$echo +$echo "Please enter C compiler option(s) used to build position-" +$echo "independent code (e.g., -fPIC, -Kpic, etc)." +$echo + +read -e -p "[]: " pic_option + +$echo +$echo "Please enter C compiler option(s) used to build shared" +$echo "libraries (e.g., -shared, -G, etc)." +$echo + +read -e -p "[]: " shared_option + +echo "c_generic_pic_option := $pic_option" > $1 +echo "c_generic_shared_option := $shared_option" >> $1 diff --git a/build/c/generic/o-e.make b/build/c/generic/o-e.make new file mode 100644 index 0000000..4a88a0f --- /dev/null +++ b/build/c/generic/o-e.make @@ -0,0 +1,28 @@ +# file : build/c/generic/o-e.make +# author : Boris Kolpackov <boris@codesynthesis.com> +# copyright : Copyright (c) 2004-2010 Code Synthesis Tools CC +# license : GNU GPL v2; see accompanying LICENSE file + +$(call include,$(bld_root)/c/generic/configuration.make) + +ifneq ($(c_extra_lib_paths),) +vpath %.so $(c_extra_lib_paths) +vpath %.a $(c_extra_lib_paths) +endif + +$(out_base)/%: ld := $(c_generic) +$(out_base)/%: expand-l = $(shell sed -e 's%^rpath:\(.*\)%%' $1) + +ifeq ($(out_base),$(src_base)) +$(out_base)/%: $(out_base)/%.o +else +$(out_base)/%: $(out_base)/%.o | $$(dir $$@). +endif + $(call message,ld $@,$(ld) \ +$(c_extra_options) $(ld_options) $(c_ld_extra_options) -o $@ \ +$(foreach f,$^,$(if $(patsubst %.l,,$f),$f,$(call expand-l,$f))) $(c_extra_libs)) + +.PHONY: $(out_base)/%.o.clean + +$(out_base)/%.o.clean: + $(call message,rm $(basename $(basename $@)),rm -f $(basename $@) $(basename $(basename $@))) diff --git a/build/c/generic/o-l.make b/build/c/generic/o-l.make new file mode 100644 index 0000000..cee21af --- /dev/null +++ b/build/c/generic/o-l.make @@ -0,0 +1,64 @@ +# file : build/c/generic/o-l.make +# author : Boris Kolpackov <boris@codesynthesis.com> +# copyright : Copyright (c) 2004-2010 Code Synthesis Tools CC +# license : GNU GPL v2; see accompanying LICENSE file + +$(call include,$(bld_root)/c/generic/configuration.make) + +ifeq ($(ld_lib_type),shared) +$(call include,$(bld_root)/c/generic/configuration-sl.make) +endif + +ifneq ($(c_extra_lib_paths),) +vpath %.so $(c_extra_lib_paths) +vpath %.a $(c_extra_lib_paths) +endif + +ifdef ld_lib_type + +.PHONY: $(out_base)/%.l.o.clean + +ifeq ($(ld_lib_type),archive) + +$(out_base)/%.l: ar := $(ld_lib_ar) +$(out_base)/%.l: ar_options ?= -rc + +$(out_base)/%.l: ranlib := $(ld_lib_ranlib) +$(out_base)/%.l: ranlib_options ?= + +ifeq ($(out_base),$(src_base)) +$(out_base)/%.l: +else +$(out_base)/%.l: | $$(dir $$@). +endif + $(call message,ar $@,$(ar) $(ar_options) $(@D)/lib$(basename $(@F)).a $(filter %.o,$^)) + $(call message,,$(ranlib) $(ranlib_options) $(@D)/lib$(basename $(@F)).a) + $(call message,,echo "$(@D)/lib$(basename $(@F)).a" >$@) + $(call message,,echo "$(patsubst %.l,`cat %.l`,$(filter %.a %.so %.l,$^))" | xargs -n 1 echo >>$@) + +$(out_base)/%.l.o.clean: + $(call message,rm $$1,rm -f $$1 $(@D)/$(patsubst %.l.o.clean,lib%.a,$(@F)),$(basename $(basename $@))) + +else + +$(out_base)/%.l: ld := $(c_generic) +$(out_base)/%.l: c_pic_options := $(c_generic_pic_option) +$(out_base)/%.l: expand-l = $(shell sed -e 's%^rpath:\(.*\)%%' $1) + +ifeq ($(out_base),$(src_base)) +$(out_base)/%.l: +else +$(out_base)/%.l: | $$(dir $$@). +endif + $(call message,ld $@,$(ld) $(c_generic_shared_option) \ +$(c_extra_options) $(ld_options) $(c_ld_extra_options) -o $(@D)/lib$(basename $(@F)).so \ +$(foreach f,$^,$(if $(patsubst %.l,,$f),$f,$(call expand-l,$f))) $(c_extra_libs)) + $(call message,,echo "$(@D)/lib$(basename $(@F)).so" >$@) + $(call message,,echo "rpath:$(@D)" >>$@) + $(call message,,echo "$(patsubst %.l,`cat %.l`,$(filter %.a %.so %.l,$^))" | xargs -n 1 echo >>$@) + +$(out_base)/%.l.o.clean: + $(call message,rm $$1,rm -f $$1 $(@D)/$(patsubst %.l.o.clean,lib%.so,$(@F)),$(basename $(basename $@))) + +endif +endif diff --git a/build/c/gnu/c-d.make b/build/c/gnu/c-d.make new file mode 100644 index 0000000..d7e6c57 --- /dev/null +++ b/build/c/gnu/c-d.make @@ -0,0 +1,59 @@ +# file : build/c/gnu/c-o.make +# author : Boris Kolpackov <boris@codesynthesis.com> +# copyright : Copyright (c) 2004-2010 Code Synthesis Tools CC +# license : GNU GPL v2; see accompanying LICENSE file + +$(call include-once,$(bld_root)/c/cpp-options.make,$(out_base)) +$(call include,$(bld_root)/c/gnu/configuration.make) + +# Make will try to build dependecies (since they are ultimately included +# files) during configuartion phase without c_gnu being discovered yet. +# This is also why dependecies should be included with -include. +# +ifdef c_gnu + +$(out_base)/%.o.d: c := $(c_gnu) +$(out_base)/%.o.d: cpp_options ?= + +#@@ This needs to be shared with c-o. +# +#@@ wrong prefix +# +$(out_base)/%.o.d: expand-cpp-options-impl = \ +$(if $1,$(shell sed -e 's%include: \(.*\)%\1%' -e t -e d $1)) + +$(out_base)/%.o.d: expand-cpp-options = \ +$(call expand-cpp-options-impl,$(filter %.cpp-options,$1)) + +.PRECIOUS: $(out_base)/%.o.d + +ifeq ($(out_base),$(src_base)) +$(out_base)/%.o.d: $(src_base)/%.$(c_s_suffix) +else +$(out_base)/%.o.d: $(src_base)/%.$(c_s_suffix) | $$(dir $$@). +endif + $(call message,,if test -f $@; then mv $@ $@.old; fi && \ +$(c) $(cpp_options) $(call expand-cpp-options,$^) $(c_pp_extra_options) \ +$(c_extra_options) -M -MG -MP -MQ $@ -MQ $(basename $@) $< | \ +$(bld_root)/c/gnu/dep $(out_base) $(filter %.cpp-options,$^) >$@ && \ +if test -f $@.old; then if cmp -s $@ $@.old; then rm -f $@.old && false; \ +else rm -f $@.old && true; fi fi) + +ifneq ($(out_base),$(src_base)) + +$(out_base)/%.o.d: $(out_base)/%.$(c_s_suffix) | $$(dir $$@). + $(call message,,if test -f $@; then mv $@ $@.old; fi && \ +$(c) $(cpp_options) $(call expand-cpp-options,$^) $(c_pp_extra_options) \ +$(c_extra_options) -M -MG -MP -MQ $@ -MQ $(basename $@) $< | \ +$(bld_root)/c/gnu/dep $(out_base) $(filter %.cpp-options,$^) >$@ && \ +if test -f $@.old; then if cmp -s $@ $@.old; then rm -f $@.old && false; \ +else rm -f $@.old && true; fi fi) + +endif + +.PHONY: $(out_base)/%.o.d.$(c_s_suffix).clean + +$(out_base)/%.o.d.$(c_s_suffix).clean: + $(call message,rm $$1,rm -f $$1,$(basename $(basename $@))) + +endif diff --git a/build/c/gnu/c-o.make b/build/c/gnu/c-o.make new file mode 100644 index 0000000..9f5ecdd --- /dev/null +++ b/build/c/gnu/c-o.make @@ -0,0 +1,42 @@ +# file : build/c/gnu/c-o.make +# author : Boris Kolpackov <boris@codesynthesis.com> +# copyright : Copyright (c) 2004-2010 Code Synthesis Tools CC +# license : GNU GPL v2; see accompanying LICENSE file + +$(call include-once,$(bld_root)/c/cpp-options.make,$(out_base)) +$(call include,$(bld_root)/c/gnu/configuration.make) + +$(out_base)/%.o: c := $(c_gnu) +$(out_base)/%.o: c_options := $(c_gnu_optimization_options) $(c_gnu_debugging_options) + +#@@ wrong prefix +# +$(out_base)/%.o: expand-cpp-options-impl = \ +$(if $1,$(shell sed -e 's%include: \(.*\)%\1%' -e t -e d $1)) + +$(out_base)/%.o: expand-cpp-options = \ +$(call expand-cpp-options-impl,$(filter %.cpp-options,$1)) + +ifeq ($(out_base),$(src_base)) +$(out_base)/%.o: $(src_base)/%.$(c_s_suffix) +else +$(out_base)/%.o: $(src_base)/%.$(c_s_suffix) | $$(dir $$@). +endif + $(call message,c $<,$(c) \ +$(cpp_options) $(call expand-cpp-options,$^) $(c_pp_extra_options) $(c_options) \ +$(c_pic_options) $(subst y,-fexceptions,$(filter y,$(c_exceptions))) $(c_extra_options) -o $@ -c $<) + + +ifneq ($(out_base),$(src_base)) + +$(out_base)/%.o: $(out_base)/%.$(c_s_suffix) | $$(dir $$@). + $(call message,c $<,$(c) \ +$(cpp_options) $(call expand-cpp-options,$^) $(c_pp_extra_options) $(c_options) \ +$(c_pic_options) $(subst y,-fexceptions,$(filter y,$(c_exceptions))) $(c_extra_options) -o $@ -c $<) + +endif + +.PHONY: $(out_base)/%.o.$(c_s_suffix).clean + +$(out_base)/%.o.$(c_s_suffix).clean: + $(call message,rm $$1,rm -f $$1,$(basename $(basename $@))) diff --git a/build/c/gnu/configuration-rules.make b/build/c/gnu/configuration-rules.make new file mode 100644 index 0000000..478db2d --- /dev/null +++ b/build/c/gnu/configuration-rules.make @@ -0,0 +1,15 @@ +# file : build/c/gnu/configuration-rules.make +# author : Boris Kolpackov <boris@codesynthesis.com> +# copyright : Copyright (c) 2004-2010 Code Synthesis Tools CC +# license : GNU GPL v2; see accompanying LICENSE file + +$(dcf_root)/c/gnu/configuration-dynamic.make: | $(dcf_root)/c/gnu/. + $(call message,,$(bld_root)/c/gnu/configure $@ $(c_optimize)) + +ifndef %foreign% + +disfigure:: + $(call message,rm $(dcf_root)/c/gnu/configuration-dynamic.make,\ +rm -f $(dcf_root)/c/gnu/configuration-dynamic.make) + +endif diff --git a/build/c/gnu/configuration-static.make b/build/c/gnu/configuration-static.make new file mode 100644 index 0000000..eb00863 --- /dev/null +++ b/build/c/gnu/configuration-static.make @@ -0,0 +1,4 @@ +# file : build/c/gnu/configuration-static.make +# author : Boris Kolpackov <boris@codesynthesis.com> +# copyright : Copyright (c) 2004-2010 Code Synthesis Tools CC +# license : GNU GPL v2; see accompanying LICENSE file diff --git a/build/c/gnu/configuration.make b/build/c/gnu/configuration.make new file mode 100644 index 0000000..c2e4a32 --- /dev/null +++ b/build/c/gnu/configuration.make @@ -0,0 +1,34 @@ +# file : build/c/gnu/configuration.make +# author : Boris Kolpackov <boris@codesynthesis.com> +# copyright : Copyright (c) 2004-2010 Code Synthesis Tools CC +# license : GNU GPL v2; see accompanying LICENSE file + +$(call include-once,$(bld_root)/c/gnu/configuration-rules.make,$(dcf_root)) + +# Static configuration. +# +$(call include,$(bld_root)/c/gnu/configuration-static.make) + +ifneq ($(bld_root),$(scf_root)) +$(call -include,$(scf_root)/c/gnu/configuration-static.make) +endif + +# Dynamic configuration. +# +c_gnu := +c_gnu_optimization_options := + +$(call -include,$(dcf_root)/c/gnu/configuration-dynamic.make) + +ifdef c_gnu + +c_gnu_debugging_options := $(if $(findstring y,$(c_debug)),-g) + +$(out_root)/%: c_gnu_debugging_options := $(c_gnu_debugging_options) +$(out_root)/%: c_gnu_optimization_options := $(c_gnu_optimization_options) + +else + +.NOTPARALLEL: + +endif diff --git a/build/c/gnu/configure b/build/c/gnu/configure new file mode 100755 index 0000000..5695ba4 --- /dev/null +++ b/build/c/gnu/configure @@ -0,0 +1,55 @@ +#! /usr/bin/env bash + +# file : build/c/gnu/configure +# author : Boris Kolpackov <boris@codesynthesis.com> +# copyright : Copyright (c) 2004-2010 Code Synthesis Tools CC +# license : GNU GPL v2; see accompanying LICENSE file + +# $1 out file +# $2 optimize (y/n) +# +# bld_root - build root +# project_name - project name +# + + +source $bld_root/dialog.bash + +$echo +$echo +$echo "configuring '$project_name'" +$echo +$echo + +$echo +$echo "Please enter the gcc binary you would like to use, for example 'gcc-3.4'," +$echo "'/usr/local/bin/gcc' or 'distcc gcc'." +$echo + +c_gnu=`read_path --command gcc` +c_gnu_libraries=`$c_gnu -print-search-dirs | sed -e 's/libraries: =//p' -e d` + + +optimization= + +if [ "$2" == "y" ]; then + + $echo + $echo "Please select the optimization level you would like to use:" + $echo + $echo "(1) -O1 [Tries to reduce code size and execution time, without" + $echo " performing any optimizations that take a great deal of" + $echo " compilation time.]" + $echo "(2) -O2 [Performs nearly all supported optimizations that do not" + $echo " involve a space-speed tradeoff.]" + $echo "(3) -O3 [Optimize even more.]" + $echo "(4) -Os [Optimize for size.]" + $echo + + optimization=`read_option "-O1 -O2 -O3 -Os" "-O2"` + +fi + +echo "c_gnu := $c_gnu" > $1 +echo "c_gnu_libraries := $c_gnu_libraries" >> $1 +echo "c_gnu_optimization_options := $optimization" >> $1 diff --git a/build/c/gnu/dep b/build/c/gnu/dep new file mode 100755 index 0000000..e0c0544 --- /dev/null +++ b/build/c/gnu/dep @@ -0,0 +1,58 @@ +#! /usr/bin/env bash + +# file : build/c/gnu/dep +# author : Boris Kolpackov <boris@codesynthesis.com> +# copyright : Copyright (c) 2004-2010 Code Synthesis Tools CC +# license : GNU GPL v2; see accompanying LICENSE file + +# Post-process generated dependency information. +# +# $1 current project's $(out_base) +# $2 - $N optional .cpp-options files + +out_base=$1 +shift + +files=$* + +#echo $out_base +#echo $files + +script= + +function gen_script () +{ + while [ "$1" ]; do + prefix=$1 + shift + + path=$1 + shift + + # Besides unresolved paths also replace default installation + # targets (/usr/include and /usr/local/include). + # + script="$script"\ +"s \\ $prefix \\ $path$prefix g;"\ +"s \\ /usr/include/$prefix \\ $path$prefix g;"\ +"s \\ /usr/local/include/$prefix \\ $path$prefix g;"\ +"s ^$prefix $path$prefix ;"\ +"s ^/usr/include/$prefix $path$prefix ;"\ +"s ^/usr/local/include/$prefix $path$prefix ;" + done +} + +if [ "$files" ]; then + prefixes=`sed -e 's%^prefix: \(.*\)$%\1%' -e t -e d $files` + gen_script $prefixes +fi + +# The last part of the script translates all file names that don't start +# with / (that is, local generated files) to files in $out_base. Note that +# it is assumed that such files are never installed and therefore there is +# no way get around the situation where this file is picket up from some +# other place (e.g., /usr/include). +# +epilogue="s% \([^/ \\\\]\)% $out_base/\1%g;s%^\([^/ ].*:\)%$out_base/\1%" + +exec sed -e "$script$epilogue" diff --git a/build/c/gnu/o-e.make b/build/c/gnu/o-e.make new file mode 100644 index 0000000..a1da582 --- /dev/null +++ b/build/c/gnu/o-e.make @@ -0,0 +1,40 @@ +# file : build/c/gnu/o-e.make +# author : Boris Kolpackov <boris@codesynthesis.com> +# copyright : Copyright (c) 2004-2010 Code Synthesis Tools CC +# license : GNU GPL v2; see accompanying LICENSE file + +$(call include,$(bld_root)/c/gnu/configuration.make) + +#@@ should it be lib%.so? +# +ifneq ($(c_extra_lib_paths),) +vpath %.so $(c_extra_lib_paths) +vpath %.a $(c_extra_lib_paths) +endif + +ifneq ($(c_gnu_libraries),) +vpath %.so $(c_gnu_libraries) +vpath %.a $(c_gnu_libraries) +endif + +$(out_base)/%: ld := $(c_gnu) +$(out_base)/%: ld_options := $(c_gnu_optimization_options) $(c_gnu_debugging_options) $(c_ld_extra_options) + +$(out_base)/%: expand-l = $(if $(subst n,,$(c_rpath)),\ +$(shell sed -e 's%^rpath:\(.*\)%-Wl,-rpath,\1%' $1),\ +$(shell sed -e 's%^rpath:\(.*\)%%' $1)) + +ifeq ($(out_base),$(src_base)) +$(out_base)/%: $(out_base)/%.o +else +$(out_base)/%: $(out_base)/%.o | $$(dir $$@). +endif + $(call message,ld $@,$(ld) \ +$(c_extra_options) $(ld_options) $(c_ld_extra_options) -o $@ \ +$(foreach f,$^,$(if $(patsubst %.l,,$f),$f,$(call expand-l,$f))) $(c_extra_libs)) + + +.PHONY: $(out_base)/%.o.clean + +$(out_base)/%.o.clean: + $(call message,rm $(basename $(basename $@)),rm -f $(basename $@) $(basename $(basename $@))) diff --git a/build/c/gnu/o-l.make b/build/c/gnu/o-l.make new file mode 100644 index 0000000..5e66650 --- /dev/null +++ b/build/c/gnu/o-l.make @@ -0,0 +1,71 @@ +# file : build/c/gnu/o-l.make +# author : Boris Kolpackov <boris@codesynthesis.com> +# copyright : Copyright (c) 2004-2010 Code Synthesis Tools CC +# license : GNU GPL v2; see accompanying LICENSE file + +$(call include,$(bld_root)/c/gnu/configuration.make) + +ifneq ($(c_extra_lib_paths),) +vpath %.so $(c_extra_lib_paths) +vpath %.a $(c_extra_lib_paths) +endif + +ifneq ($(c_gnu_libraries),) +vpath %.so $(c_gnu_libraries) +vpath %.a $(c_gnu_libraries) +endif + +ifdef ld_lib_type + +.PHONY: $(out_base)/%.l.o.clean + +ifeq ($(ld_lib_type),archive) + +$(out_base)/%.l: ar := $(ld_lib_ar) +$(out_base)/%.l: ar_options ?= -rc + +$(out_base)/%.l: ranlib := $(ld_lib_ranlib) +$(out_base)/%.l: ranlib_options ?= + +ifeq ($(out_base),$(src_base)) +$(out_base)/%.l: +else +$(out_base)/%.l: | $$(dir $$@). +endif + $(call message,ar $@,$(ar) $(ar_options) $(@D)/lib$(basename $(@F)).a $(filter %.o,$^)) + $(call message,,$(ranlib) $(ranlib_options) $(@D)/lib$(basename $(@F)).a) + $(call message,,echo "$(@D)/lib$(basename $(@F)).a" >$@) + $(call message,,echo "$(patsubst %.l,`cat %.l`,$(filter %.a %.so %.l,$^))" | xargs -n 1 echo >>$@) + +$(out_base)/%.l.o.clean: + $(call message,rm $$1,rm -f $$1 $(@D)/$(patsubst %.l.o.clean,lib%.a,$(@F)),$(basename $(basename $@))) + +else + +$(out_base)/%.l: ld := $(c_gnu) +$(out_base)/%.l: ld_options := $(c_gnu_optimization_options) $(c_gnu_debugging_options) +$(out_base)/%.l: c_pic_options := -fPIC +$(out_base)/%.l: comma_ := , + +$(out_base)/%.l: expand-l = $(if $(subst n,,$(c_rpath)),\ +$(shell sed -e 's%^rpath:\(.*\)%-Wl,-rpath,\1%' $1),\ +$(shell sed -e 's%^rpath:\(.*\)%%' $1)) + +ifeq ($(out_base),$(src_base)) +$(out_base)/%.l: +else +$(out_base)/%.l: | $$(dir $$@). +endif + $(call message,ld $@,$(ld) -shared \ +$(c_extra_options) $(ld_options) $(c_ld_extra_options) \ +-o $(@D)/lib$(basename $(@F)).so -Wl$(comma_)-soname=lib$(basename $(@F)).so \ +$(foreach f,$^,$(if $(patsubst %.l,,$f),$f,$(call expand-l,$f))) $(c_extra_libs)) + $(call message,,echo "$(@D)/lib$(basename $(@F)).so" >$@) + $(call message,,echo "rpath:$(@D)" >>$@) + $(call message,,echo "$(patsubst %.l,`cat %.l`,$(filter %.a %.so %.l,$^))" | xargs -n 1 echo >>$@) + +$(out_base)/%.l.o.clean: + $(call message,rm $$1,rm -f $$1 $(@D)/$(patsubst %.l.o.clean,lib%.so,$(@F)),$(basename $(basename $@))) + +endif +endif diff --git a/build/c/intel/c-d.make b/build/c/intel/c-d.make new file mode 100644 index 0000000..aa6a559 --- /dev/null +++ b/build/c/intel/c-d.make @@ -0,0 +1,59 @@ +# file : build/c/intel/c-o.make +# author : Boris Kolpackov <boris@codesynthesis.com> +# copyright : Copyright (c) 2004-2010 Code Synthesis Tools CC +# license : GNU GPL v2; see accompanying LICENSE file + +$(call include-once,$(bld_root)/c/cpp-options.make,$(out_base)) +$(call include,$(bld_root)/c/intel/configuration.make) + +# Make will try to build dependecies (since they are ultimately included +# files) during configuartion phase without c_intel being discovered yet. +# This is also why dependecies should be included with -include. +# +ifdef c_intel + +$(out_base)/%.o.d: c := $(c_intel) +$(out_base)/%.o.d: cpp_options ?= + +#@@ This needs to be shared with c-o. +# +#@@ wrong prefix +# +$(out_base)/%.o.d: expand-cpp-options-impl = \ +$(if $1,$(shell sed -e 's%include: \(.*\)%\1%' -e t -e d $1)) + +$(out_base)/%.o.d: expand-cpp-options = \ +$(call expand-cpp-options-impl,$(filter %.cpp-options,$1)) + +.PRECIOUS: $(out_base)/%.o.d + +ifeq ($(out_base),$(src_base)) +$(out_base)/%.o.d: $(src_base)/%.$(c_s_suffix) +else +$(out_base)/%.o.d: $(src_base)/%.$(c_s_suffix) | $$(dir $$@). +endif + $(call message,,if test -f $@; then mv $@ $@.old; fi && \ +$(c) $(cpp_options) $(call expand-cpp-options,$^) $(c_pp_extra_options) \ +$(c_extra_options) -M -MG -MP -MQ $@ -MQ $(basename $@) $< | \ +$(bld_root)/c/intel/dep $(out_base) $(filter %.cpp-options,$^) >$@ && \ +if test -f $@.old; then if cmp -s $@ $@.old; then rm -f $@.old && false; \ +else rm -f $@.old && true; fi fi) + +ifneq ($(out_base),$(src_base)) + +$(out_base)/%.o.d: $(out_base)/%.$(c_s_suffix) | $$(dir $$@). + $(call message,,if test -f $@; then mv $@ $@.old; fi && \ +$(c) $(cpp_options) $(call expand-cpp-options,$^) $(c_pp_extra_options) \ +$(c_extra_options) -M -MG -MP -MQ $@ -MQ $(basename $@) $< | \ +$(bld_root)/c/intel/dep $(out_base) $(filter %.cpp-options,$^) >$@ && \ +if test -f $@.old; then if cmp -s $@ $@.old; then rm -f $@.old && false; \ +else rm -f $@.old && true; fi fi) + +endif + +.PHONY: $(out_base)/%.o.d.$(c_s_suffix).clean + +$(out_base)/%.o.d.$(c_s_suffix).clean: + $(call message,rm $$1,rm -f $$1,$(basename $(basename $@))) + +endif diff --git a/build/c/intel/c-o.make b/build/c/intel/c-o.make new file mode 100644 index 0000000..3e359aa --- /dev/null +++ b/build/c/intel/c-o.make @@ -0,0 +1,41 @@ +# file : build/c/intel/c-o.make +# author : Boris Kolpackov <boris@codesynthesis.com> +# copyright : Copyright (c) 2004-2010 Code Synthesis Tools CC +# license : GNU GPL v2; see accompanying LICENSE file + +$(call include-once,$(bld_root)/c/cpp-options.make,$(out_base)) +$(call include,$(bld_root)/c/intel/configuration.make) + +$(out_base)/%.o: c := $(c_intel) +$(out_base)/%.o: c_options := $(c_intel_optimization_options) $(c_intel_debugging_options) + +#@@ wrong prefix +# +$(out_base)/%.o: expand-cpp-options-impl = \ +$(if $1,$(shell sed -e 's%include: \(.*\)%\1%' -e t -e d $1)) + +$(out_base)/%.o: expand-cpp-options = \ +$(call expand-cpp-options-impl,$(filter %.cpp-options,$1)) + +ifeq ($(out_base),$(src_base)) +$(out_base)/%.o: $(src_base)/%.$(c_s_suffix) +else +$(out_base)/%.o: $(src_base)/%.$(c_s_suffix) | $$(dir $$@). +endif + $(call message,c $<,$(c) \ +$(cpp_options) $(call expand-cpp-options,$^) $(c_pp_extra_options) $(c_options) \ +$(c_pic_options) $(subst y,-fexceptions,$(filter y,$(c_exceptions))) $(c_extra_options) -o $@ -c $<) + +ifneq ($(out_base),$(src_base)) + +$(out_base)/%.o: $(out_base)/%.$(c_s_suffix) | $$(dir $$@). + $(call message,c $<,$(c) \ +$(cpp_options) $(call expand-cpp-options,$^) $(c_pp_extra_options) $(c_options) \ +$(c_pic_options) $(subst y,-fexceptions,$(filter y,$(c_exceptions))) $(c_extra_options) -o $@ -c $<) + +endif + +.PHONY: $(out_base)/%.o.$(c_s_suffix).clean + +$(out_base)/%.o.$(c_s_suffix).clean: + $(call message,rm $$1,rm -f $$1,$(basename $(basename $@))) diff --git a/build/c/intel/configuration-rules.make b/build/c/intel/configuration-rules.make new file mode 100644 index 0000000..e464e00 --- /dev/null +++ b/build/c/intel/configuration-rules.make @@ -0,0 +1,15 @@ +# file : build/c/intel/configuration-rules.make +# author : Boris Kolpackov <boris@codesynthesis.com> +# copyright : Copyright (c) 2004-2010 Code Synthesis Tools CC +# license : GNU GPL v2; see accompanying LICENSE file + +$(dcf_root)/c/intel/configuration-dynamic.make: | $(dcf_root)/c/intel/. + $(call message,,$(bld_root)/c/intel/configure $@ $(c_optimize)) + +ifndef %foreign% + +disfigure:: + $(call message,rm $(dcf_root)/c/intel/configuration-dynamic.make,\ +rm -f $(dcf_root)/c/intel/configuration-dynamic.make) + +endif diff --git a/build/c/intel/configuration-static.make b/build/c/intel/configuration-static.make new file mode 100644 index 0000000..29f44b1 --- /dev/null +++ b/build/c/intel/configuration-static.make @@ -0,0 +1,4 @@ +# file : build/c/intel/configuration-static.make +# author : Boris Kolpackov <boris@codesynthesis.com> +# copyright : Copyright (c) 2004-2010 Code Synthesis Tools CC +# license : GNU GPL v2; see accompanying LICENSE file diff --git a/build/c/intel/configuration.make b/build/c/intel/configuration.make new file mode 100644 index 0000000..5e3e38f --- /dev/null +++ b/build/c/intel/configuration.make @@ -0,0 +1,34 @@ +# file : build/c/intel/configuration.make +# author : Boris Kolpackov <boris@codesynthesis.com> +# copyright : Copyright (c) 2004-2010 Code Synthesis Tools CC +# license : GNU GPL v2; see accompanying LICENSE file + +$(call include-once,$(bld_root)/c/intel/configuration-rules.make,$(dcf_root)) + +# Static configuration. +# +$(call include,$(bld_root)/c/intel/configuration-static.make) + +ifneq ($(bld_root),$(scf_root)) +$(call -include,$(scf_root)/c/intel/configuration-static.make) +endif + +# Dynamic configuration. +# +c_intel := +c_intel_optimization_options := + +$(call -include,$(dcf_root)/c/intel/configuration-dynamic.make) + +ifdef c_intel + +c_intel_debugging_options := $(if $(findstring y,$(c_debug)),-g) + +$(out_root)/%: c_intel_debugging_options := $(c_intel_debugging_options) +$(out_root)/%: c_intel_optimization_options := $(c_intel_optimization_options) + +else + +.NOTPARALLEL: + +endif diff --git a/build/c/intel/configure b/build/c/intel/configure new file mode 100755 index 0000000..0d1382d --- /dev/null +++ b/build/c/intel/configure @@ -0,0 +1,52 @@ +#! /usr/bin/env bash + +# file : build/c/intel/configure +# author : Boris Kolpackov <boris@codesynthesis.com> +# copyright : Copyright (c) 2004-2010 Code Synthesis Tools CC +# license : GNU GPL v2; see accompanying LICENSE file + +# $1 out file +# $2 optimize (y/n) +# +# bld_root - build root +# project_name - project name +# + + +source $bld_root/dialog.bash + +$echo +$echo +$echo "configuring '$project_name'" +$echo +$echo + +$echo +$echo "Please enter the icc binary you would like to use, for example " +$echo "'/opt/intel_cc_80/bin/icc'." +$echo + +c_intel=`read_path --command icc` +c_intel_libraries=`$c_intel -print-search-dirs | sed -e 's/libraries: =//p' -e d` + +# Intel optimizes by default. +# +optimization=-O0 + +if [ "$2" == "y" ]; then + + $echo + $echo "Please select the optimization level you would like to use:" + $echo + $echo "(1) -O1 [Enable optimizations.]" + $echo "(2) -O2 [Same as -O1.]" + $echo "(3) -O3 [As -O2 plus more aggressive optimizations that may not" + $echo " improve performance for all programs.]" + $echo + + optimization=`read_option "-O1 -O2 -O3" "-O2"` +fi + +echo "c_intel := $c_intel" > $1 +echo "c_intel_libraries := $c_intel_libraries" >> $1 +echo "c_intel_optimization_options := $optimization" >> $1 diff --git a/build/c/intel/dep b/build/c/intel/dep new file mode 100755 index 0000000..3a09302 --- /dev/null +++ b/build/c/intel/dep @@ -0,0 +1,58 @@ +#! /usr/bin/env bash + +# file : build/c/intel/dep +# author : Boris Kolpackov <boris@codesynthesis.com> +# copyright : Copyright (c) 2004-2010 Code Synthesis Tools CC +# license : GNU GPL v2; see accompanying LICENSE file + +# Post-process generated dependency information. +# +# $1 current project's $(out_base) +# $2 - $N optional .cpp-options files + +out_base=$1 +shift + +files=$* + +#echo $out_base +#echo $files + +script= + +function gen_script () +{ + while [ "$1" ]; do + prefix=$1 + shift + + path=$1 + shift + + # Besides unresolved paths also replace default installation + # targets (/usr/include and /usr/local/include). + # + script="$script"\ +"s \\ $prefix \\ $path$prefix g;"\ +"s \\ /usr/include/$prefix \\ $path$prefix g;"\ +"s \\ /usr/local/include/$prefix \\ $path$prefix g;"\ +"s ^$prefix $path$prefix ;"\ +"s ^/usr/include/$prefix $path$prefix ;"\ +"s ^/usr/local/include/$prefix $path$prefix ;" + done +} + +if [ "$files" ]; then + prefixes=`sed -e 's%^prefix: \(.*\)$%\1%' -e t -e d $files` + gen_script $prefixes +fi + +# The last part of the script translates all file names that don't start +# with / (that is, local generated files) to files in $out_base. Note that +# it is assumed that such files are never installed and therefore there is +# no way get around the situation where this file is picket up from some +# other place (e.g., /usr/include). +# +epilogue="s% \([^/ \\\\]\)% $out_base/\1%g;s%^\([^/ ].*:\)%$out_base/\1%" + +exec sed -e "$script$epilogue" diff --git a/build/c/intel/o-e.make b/build/c/intel/o-e.make new file mode 100644 index 0000000..7442637 --- /dev/null +++ b/build/c/intel/o-e.make @@ -0,0 +1,39 @@ +# file : build/c/intel/o-e.make +# author : Boris Kolpackov <boris@codesynthesis.com> +# copyright : Copyright (c) 2004-2010 Code Synthesis Tools CC +# license : GNU GPL v2; see accompanying LICENSE file + +$(call include,$(bld_root)/c/intel/configuration.make) + +#@@ should it be lib%.so? +# +ifneq ($(c_extra_lib_paths),) +vpath %.so $(c_extra_lib_paths) +vpath %.a $(c_extra_lib_paths) +endif + +ifneq ($(c_intel_libraries),) +vpath %.so $(c_intel_libraries) +vpath %.a $(c_intel_libraries) +endif + +$(out_base)/%: ld := $(c_intel) +$(out_base)/%: ld_options := $(c_intel_optimization_options) $(c_intel_debugging_options) $(c_ld_extra_options) + +$(out_base)/%: expand-l = $(if $(subst n,,$(c_rpath)),\ +$(shell sed -e 's%^rpath:\(.*\)%-Wl,-rpath,\1%' $1),\ +$(shell sed -e 's%^rpath:\(.*\)%%' $1)) + +ifeq ($(out_base),$(src_base)) +$(out_base)/%: $(out_base)/%.o +else +$(out_base)/%: $(out_base)/%.o | $$(dir $$@). +endif + $(call message,ld $@,$(ld) \ +$(c_extra_options) $(ld_options) $(c_ld_extra_options) -o $@ \ +$(foreach f,$^,$(if $(patsubst %.l,,$f),$f,$(call expand-l,$f))) $(c_extra_libs)) + +.PHONY: $(out_base)/%.o.clean + +$(out_base)/%.o.clean: + $(call message,rm $(basename $(basename $@)),rm -f $(basename $@) $(basename $(basename $@))) diff --git a/build/c/intel/o-l.make b/build/c/intel/o-l.make new file mode 100644 index 0000000..818a4ca --- /dev/null +++ b/build/c/intel/o-l.make @@ -0,0 +1,71 @@ +# file : build/c/intel/o-l.make +# author : Boris Kolpackov <boris@codesynthesis.com> +# copyright : Copyright (c) 2004-2010 Code Synthesis Tools CC +# license : GNU GPL v2; see accompanying LICENSE file + +$(call include,$(bld_root)/c/intel/configuration.make) + +ifneq ($(c_extra_lib_paths),) +vpath %.so $(c_extra_lib_paths) +vpath %.a $(c_extra_lib_paths) +endif + +ifneq ($(c_intel_libraries),) +vpath %.so $(c_intel_libraries) +vpath %.a $(c_intel_libraries) +endif + +ifdef ld_lib_type + +.PHONY: $(out_base)/%.l.o.clean + +ifeq ($(ld_lib_type),archive) + +$(out_base)/%.l: ar := $(ld_lib_ar) +$(out_base)/%.l: ar_options ?= -rc + +$(out_base)/%.l: ranlib := $(ld_lib_ranlib) +$(out_base)/%.l: ranlib_options ?= + +ifeq ($(out_base),$(src_base)) +$(out_base)/%.l: +else +$(out_base)/%.l: | $$(dir $$@). +endif + $(call message,ar $@,$(ar) $(ar_options) $(@D)/lib$(basename $(@F)).a $(filter %.o,$^)) + $(call message,,$(ranlib) $(ranlib_options) $(@D)/lib$(basename $(@F)).a) + $(call message,,echo "$(@D)/lib$(basename $(@F)).a" >$@) + $(call message,,echo "$(patsubst %.l,`cat %.l`,$(filter %.a %.so %.l,$^))" | xargs -n 1 echo >>$@) + +$(out_base)/%.l.o.clean: + $(call message,rm $$1,rm -f $$1 $(@D)/$(patsubst %.l.o.clean,lib%.a,$(@F)),$(basename $(basename $@))) + +else + +$(out_base)/%.l: ld := $(c_intel) +$(out_base)/%.l: ld_options := $(c_intel_optimization_options) $(c_intel_debugging_options) +$(out_base)/%.l: c_pic_options := -fPIC +$(out_base)/%.l: comma_ := , + +$(out_base)/%.l: expand-l = $(if $(subst n,,$(c_rpath)),\ +$(shell sed -e 's%^rpath:\(.*\)%-Wl,-rpath,\1%' $1),\ +$(shell sed -e 's%^rpath:\(.*\)%%' $1)) + +ifeq ($(out_base),$(src_base)) +$(out_base)/%.l: +else +$(out_base)/%.l: | $$(dir $$@). +endif + $(call message,ld $@,$(ld) -shared \ +$(c_extra_options) $(ld_options) $(c_ld_extra_options) \ +-o $(@D)/lib$(basename $(@F)).so -Wl$(comma_)-soname=lib$(basename $(@F)).so \ +$(foreach f,$^,$(if $(patsubst %.l,,$f),$f,$(call expand-l,$f))) $(c_extra_libs)) + $(call message,,echo "$(@D)/lib$(basename $(@F)).so" >$@) + $(call message,,echo "rpath:$(@D)" >>$@) + $(call message,,echo "$(patsubst %.l,`cat %.l`,$(filter %.a %.so %.l,$^))" | xargs -n 1 echo >>$@) + +$(out_base)/%.l.o.clean: + $(call message,rm $$1,rm -f $$1 $(@D)/$(patsubst %.l.o.clean,lib%.so,$(@F)),$(basename $(basename $@))) + +endif +endif diff --git a/build/c/o-e.make b/build/c/o-e.make new file mode 100644 index 0000000..10469a4 --- /dev/null +++ b/build/c/o-e.make @@ -0,0 +1,10 @@ +# file : build/c/o-e.make +# author : Boris Kolpackov <boris@codesynthesis.com> +# copyright : Copyright (c) 2004-2010 Code Synthesis Tools CC +# license : GNU GPL v2; see accompanying LICENSE file + +$(call include,$(bld_root)/c/configuration.make) + +ifdef c_id +$(call include-once,$(bld_root)/c/$(c_id)/o-e.make,$(out_base)) +endif diff --git a/build/c/o-l.make b/build/c/o-l.make new file mode 100644 index 0000000..5ee8a0f --- /dev/null +++ b/build/c/o-l.make @@ -0,0 +1,11 @@ +# file : build/c/o-l.make +# author : Boris Kolpackov <boris@codesynthesis.com> +# copyright : Copyright (c) 2004-2010 Code Synthesis Tools CC +# license : GNU GPL v2; see accompanying LICENSE file + +$(call include,$(bld_root)/ld/configuration-lib.make) +$(call include,$(bld_root)/c/configuration.make) + +ifdef c_id +$(call include-once,$(bld_root)/c/$(c_id)/o-l.make,$(out_base)) +endif diff --git a/build/clean.make b/build/clean.make new file mode 100644 index 0000000..0cea632 --- /dev/null +++ b/build/clean.make @@ -0,0 +1,17 @@ +# file : build/clean.make +# author : Boris Kolpackov <boris@codesynthesis.com> +# copyright : Copyright (c) 2004-2010 Code Synthesis Tools CC +# license : GNU GPL v2; see accompanying LICENSE file + +#@@ Maybe create file aliases.make for standard aliases +# plus check for interactivity? What if some targets +# are not defined? +# + +ifdef %interactive% + +.PHONY: clean + +clean: $(out_base)/.clean + +endif diff --git a/build/configuration-static.make b/build/configuration-static.make new file mode 100644 index 0000000..3e8b727 --- /dev/null +++ b/build/configuration-static.make @@ -0,0 +1,9 @@ +# file : build/configuration-static.make +# author : Boris Kolpackov <boris@codesynthesis.com> +# copyright : Copyright (c) 2004-2010 Code Synthesis Tools CC +# license : GNU GPL v2; see accompanying LICENSE file + +# Name of the target that cleans absolutely everything. Used as +# a prerequisite of `disfigure' target. +# +build_absolute_clean_target := clean diff --git a/build/cxx/configuration-rules.make b/build/cxx/configuration-rules.make new file mode 100644 index 0000000..354791e --- /dev/null +++ b/build/cxx/configuration-rules.make @@ -0,0 +1,19 @@ +# file : build/cxx/configuration-rules.make +# author : Boris Kolpackov <boris@codesynthesis.com> +# copyright : Copyright (c) 2004-2010 Code Synthesis Tools CC +# license : GNU GPL v2; see accompanying LICENSE file + +$(dcf_root)/cxx/configuration-dynamic.make: | $(dcf_root)/cxx/. + $(call message,,$(bld_root)/cxx/configure $@ \ +"$(origin cxx_pp_options)" \ +"$(origin cxx_options)" \ +"$(origin cxx_ld_options)" \ +"$(origin cxx_libs)") + +ifndef %foreign% + +disfigure:: + $(call message,rm $(dcf_root)/cxx/configuration-dynamic.make,\ +rm -f $(dcf_root)/cxx/configuration-dynamic.make) + +endif diff --git a/build/cxx/configuration-static.make b/build/cxx/configuration-static.make new file mode 100644 index 0000000..b1339bf --- /dev/null +++ b/build/cxx/configuration-static.make @@ -0,0 +1,15 @@ +# file : build/cxx/configuration-static.make +# author : Boris Kolpackov <boris@codesynthesis.com> +# copyright : Copyright (c) 2004-2010 Code Synthesis Tools CC +# license : GNU GPL v2; see accompanying LICENSE file + +cxx_h_suffix := hxx +cxx_t_suffix := txx +cxx_i_suffix := ixx +cxx_s_suffix := cxx + +# Get user-supplied static configuration if any. +# +ifneq ($(bld_root),$(scf_root)) +$(call -include,$(scf_root)/cxx/configuration-static.make) +endif
\ No newline at end of file diff --git a/build/cxx/configuration.make b/build/cxx/configuration.make new file mode 100644 index 0000000..5ad97ae --- /dev/null +++ b/build/cxx/configuration.make @@ -0,0 +1,45 @@ +# file : build/cxx/configuration.make +# author : Boris Kolpackov <boris@codesynthesis.com> +# copyright : Copyright (c) 2004-2010 Code Synthesis Tools CC +# license : GNU GPL v2; see accompanying LICENSE file + +$(call include-once,$(bld_root)/cxx/configuration-rules.make,$(dcf_root)) + +# Static configuration. +# +$(call include,$(bld_root)/cxx/configuration-static.make) + + +# Dynamic configuration. +# +cxx_id := +cxx_optimize := +cxx_debug := +cxx_rpath := + +cxx_pp_extra_options := +cxx_extra_options := +cxx_ld_extra_options := +cxx_extra_libs := +cxx_extra_lib_paths := + +$(call -include,$(dcf_root)/cxx/configuration-dynamic.make) + +ifdef cxx_id + +$(out_root)/%: cxx_id := $(cxx_id) +$(out_root)/%: cxx_optimize := $(cxx_optimize) +$(out_root)/%: cxx_debug := $(cxx_debug) +$(out_root)/%: cxx_rpath := $(cxx_rpath) + +$(out_root)/%: cxx_pp_extra_options := $(cxx_pp_extra_options) +$(out_root)/%: cxx_extra_options := $(cxx_extra_options) +$(out_root)/%: cxx_ld_extra_options := $(cxx_ld_extra_options) +$(out_root)/%: cxx_extra_libs := $(cxx_extra_libs) +$(out_root)/%: cxx_extra_lib_paths := $(cxx_extra_lib_paths) + +else + +.NOTPARALLEL: + +endif diff --git a/build/cxx/configure b/build/cxx/configure new file mode 100755 index 0000000..033424b --- /dev/null +++ b/build/cxx/configure @@ -0,0 +1,167 @@ +#! /usr/bin/env bash + +# file : build/cxx/configure +# author : Boris Kolpackov <boris@codesynthesis.com> +# copyright : Copyright (c) 2004-2010 Code Synthesis Tools CC +# license : GNU GPL v2; see accompanying LICENSE file + +# $1 out file +# $2 origin of the cxx_pp_options make variable +# $3 origin of the cxx_options make variable +# $4 origin of the cxx_ld_options make variable +# $5 origin of the cxx_libs make variable +# +# bld_root - build root +# project_name - project name +# + +source $bld_root/dialog.bash + + +$echo +$echo +$echo "configuring '$project_name'" +$echo +$echo + +$echo +$echo "Please select the C++ compiler you would like to use:" +$echo +$echo "(1) GNU C++ (g++)" +$echo "(2) Intel C++ (icc)" +$echo "(3) Other C++ compiler" +$echo + +id=`read_option "gnu intel generic" "gnu"` + +if [ "$id" != "generic" ]; then + + $echo + $echo "Would you like the C++ compiler to optimize generated code?" + $echo + + optimize=`read_y_n y` + + + $echo + $echo "Would you like the C++ compiler to generate debug information?" + $echo + + debug=`read_y_n y` + + $echo + $echo "Embed dynamic library paths into executables (rpath)?" + $echo + + rpath=`read_y_n y` + +fi + +# pp_options +# +if [ "$2" != "undefined" ]; then + + pp_options=$cxx_pp_options + + if [ "$pp_options" ]; then + $echo + $echo "Extra C++ preprocessor options: $pp_options" + $echo + fi +else + + $echo + $echo "Please enter any extra C++ preprocessor options." + $echo + + read -e -p "[]: " pp_options +fi + + +# options +# +if [ "$3" != "undefined" ]; then + + options=$cxx_options + + if [ "$options" ]; then + $echo + $echo "Extra C++ compiler options: $options" + $echo + fi +else + + $echo + $echo "Please enter any extra C++ compiler options." + $echo + + read -p "[]: " options +fi + + +# ld_options +# +if [ "$4" != "undefined" ]; then + + ld_options=$cxx_ld_options + + if [ "$ld_options" ]; then + $echo + $echo "Extra C++ linker options: $ld_options" + $echo + fi +else + + $echo + $echo "Please enter any extra C++ linker options." + $echo + + read -e -p "[]: " ld_options +fi + + +# libs +# +if [ "$5" != "undefined" ]; then + + libs=$cxx_libs + + if [ "$libs" ]; then + $echo + $echo "Extra C++ libraries: $libs" + $echo + fi +else + + $echo + $echo "Please enter any extra C++ libraries." + $echo + + read -e -p "[]: " libs +fi + + +# Extract -L paths from the ld options. +# +paths= + +if [ "$ld_options" ]; then + paths=`echo "$ld_options" | sed -e 's/-L *\([^ ]*\)/\\ +-L\1\\ +/g' | sed -e 's/^-L\([^ ]*\)$/\1/' -e t -e d` + paths=`echo $paths | sed -e 's/ /:/g'` +fi + +echo "cxx_id := $id" >$1 + +if [ "$id" != "generic" ]; then + echo "cxx_optimize := $optimize" >>$1 + echo "cxx_debug := $debug" >>$1 + echo "cxx_rpath := $rpath" >>$1 +fi + +echo "cxx_pp_extra_options := $pp_options" >>$1 +echo "cxx_extra_options := $options" >>$1 +echo "cxx_ld_extra_options := $ld_options" >>$1 +echo "cxx_extra_libs := $libs" >>$1 +echo "cxx_extra_lib_paths := $paths" >>$1 diff --git a/build/cxx/cxx-d.make b/build/cxx/cxx-d.make new file mode 100644 index 0000000..34b80c9 --- /dev/null +++ b/build/cxx/cxx-d.make @@ -0,0 +1,10 @@ +# file : build/cxx/cxx-d.make +# author : Boris Kolpackov <boris@codesynthesis.com> +# copyright : Copyright (c) 2004-2010 Code Synthesis Tools CC +# license : GNU GPL v2; see accompanying LICENSE file + +$(call include,$(bld_root)/cxx/configuration.make) + +ifdef cxx_id +$(call include-once,$(bld_root)/cxx/$(cxx_id)/cxx-d.make,$(out_base)) +endif diff --git a/build/cxx/cxx-o.make b/build/cxx/cxx-o.make new file mode 100644 index 0000000..e01067f --- /dev/null +++ b/build/cxx/cxx-o.make @@ -0,0 +1,10 @@ +# file : build/cxx/cxx-o.make +# author : Boris Kolpackov <boris@codesynthesis.com> +# copyright : Copyright (c) 2004-2010 Code Synthesis Tools CC +# license : GNU GPL v2; see accompanying LICENSE file + +$(call include,$(bld_root)/cxx/configuration.make) + +ifdef cxx_id +$(call include-once,$(bld_root)/cxx/$(cxx_id)/cxx-o.make,$(out_base)) +endif diff --git a/build/cxx/generic/configuration-rules.make b/build/cxx/generic/configuration-rules.make new file mode 100644 index 0000000..bb4fe67 --- /dev/null +++ b/build/cxx/generic/configuration-rules.make @@ -0,0 +1,15 @@ +# file : build/cxx/generic/configuration-rules.make +# author : Boris Kolpackov <boris@codesynthesis.com> +# copyright : Copyright (c) 2004-2010 Code Synthesis Tools CC +# license : GNU GPL v2; see accompanying LICENSE file + +$(dcf_root)/cxx/generic/configuration-dynamic.make: | $(dcf_root)/cxx/generic/. + $(call message,,$(bld_root)/cxx/generic/configure $@) + +ifndef %foreign% + +disfigure:: + $(call message,rm $(dcf_root)/cxx/generic/configuration-dynamic.make,\ +rm -f $(dcf_root)/cxx/generic/configuration-dynamic.make) + +endif diff --git a/build/cxx/generic/configuration-sl-rules.make b/build/cxx/generic/configuration-sl-rules.make new file mode 100644 index 0000000..cbcf160 --- /dev/null +++ b/build/cxx/generic/configuration-sl-rules.make @@ -0,0 +1,15 @@ +# file : build/cxx/generic/configuration-sl-rules.make +# author : Boris Kolpackov <boris@codesynthesis.com> +# copyright : Copyright (c) 2004-2010 Code Synthesis Tools CC +# license : GNU GPL v2; see accompanying LICENSE file + +$(dcf_root)/cxx/generic/configuration-sl-dynamic.make: | $(dcf_root)/cxx/generic/. + $(call message,,$(bld_root)/cxx/generic/configure-sl $@) + +ifndef %foreign% + +disfigure:: + $(call message,rm $(dcf_root)/cxx/generic/configuration-sl-dynamic.make,\ +rm -f $(dcf_root)/cxx/generic/configuration-sl-dynamic.make) + +endif diff --git a/build/cxx/generic/configuration-sl.make b/build/cxx/generic/configuration-sl.make new file mode 100644 index 0000000..2a5e682 --- /dev/null +++ b/build/cxx/generic/configuration-sl.make @@ -0,0 +1,21 @@ +# file : build/cxx/generic/configuration-sl.make +# author : Boris Kolpackov <boris@codesynthesis.com> +# copyright : Copyright (c) 2004-2010 Code Synthesis Tools CC +# license : GNU GPL v2; see accompanying LICENSE file + +$(call include-once,$(bld_root)/cxx/generic/configuration-sl-rules.make,$(dcf_root)) + +# Dynamic configuration. +# +cxx_generic_pic_option := + +$(call -include,$(dcf_root)/cxx/generic/configuration-sl-dynamic.make) + +ifdef cxx_generic_pic_option + +$(out_root)/%: cxx_generic_pic_option := $(cxx_generic_pic_option) +$(out_root)/%: cxx_generic_shared_option := $(cxx_generic_shared_option) + +else +.NOTPARALLEL: +endif diff --git a/build/cxx/generic/configuration.make b/build/cxx/generic/configuration.make new file mode 100644 index 0000000..b57eaaf --- /dev/null +++ b/build/cxx/generic/configuration.make @@ -0,0 +1,22 @@ +# file : build/cxx/generic/configuration.make +# author : Boris Kolpackov <boris@codesynthesis.com> +# copyright : Copyright (c) 2004-2010 Code Synthesis Tools CC +# license : GNU GPL v2; see accompanying LICENSE file + +$(call include-once,$(bld_root)/cxx/generic/configuration-rules.make,$(dcf_root)) + +# Static configuration. +# +ifneq ($(bld_root),$(scf_root)) +$(call -include,$(scf_root)/cxx/generic/configuration-static.make) +endif + +# Dynamic configuration. +# +cxx_generic := + +$(call -include,$(dcf_root)/cxx/generic/configuration-dynamic.make) + +ifndef cxx_generic +.NOTPARALLEL: +endif diff --git a/build/cxx/generic/configure b/build/cxx/generic/configure new file mode 100755 index 0000000..48b1b59 --- /dev/null +++ b/build/cxx/generic/configure @@ -0,0 +1,28 @@ +#! /usr/bin/env bash + +# file : build/cxx/generic/configure +# author : Boris Kolpackov <boris@codesynthesis.com> +# copyright : Copyright (c) 2004-2010 Code Synthesis Tools CC +# license : GNU GPL v2; see accompanying LICENSE file + +# $1 out file +# +# bld_root - build root +# project_name - project name +# + +source $bld_root/dialog.bash + +$echo +$echo +$echo "configuring '$project_name'" +$echo +$echo + +$echo +$echo "Please enter the C++ compiler executable you would like to use." +$echo + +cxx_generic=`read_path --command` + +echo "cxx_generic := $cxx_generic" > $1 diff --git a/build/cxx/generic/configure-sl b/build/cxx/generic/configure-sl new file mode 100755 index 0000000..1c4b8b5 --- /dev/null +++ b/build/cxx/generic/configure-sl @@ -0,0 +1,37 @@ +#! /usr/bin/env bash + +# file : build/cxx/generic/configure-sl +# author : Boris Kolpackov <boris@codesynthesis.com> +# copyright : Copyright (c) 2004-2010 Code Synthesis Tools CC +# license : GNU GPL v2; see accompanying LICENSE file + +# $1 out file +# +# bld_root - build root +# project_name - project name +# + +source $bld_root/dialog.bash + +$echo +$echo +$echo "configuring '$project_name'" +$echo +$echo + +$echo +$echo "Please enter C++ compiler option(s) used to build position-" +$echo "independent code (e.g., -fPIC, -Kpic, etc)." +$echo + +read -e -p "[]: " pic_option + +$echo +$echo "Please enter C++ compiler option(s) used to build shared" +$echo "libraries (e.g., -shared, -G, etc)." +$echo + +read -e -p "[]: " shared_option + +echo "cxx_generic_pic_option := $pic_option" > $1 +echo "cxx_generic_shared_option := $shared_option" >> $1 diff --git a/build/cxx/generic/cxx-d.make b/build/cxx/generic/cxx-d.make new file mode 100644 index 0000000..53f44b1 --- /dev/null +++ b/build/cxx/generic/cxx-d.make @@ -0,0 +1,19 @@ +# file : build/cxx/generic/cxx-o.make +# author : Boris Kolpackov <boris@codesynthesis.com> +# copyright : Copyright (c) 2004-2010 Code Synthesis Tools CC +# license : GNU GPL v2; see accompanying LICENSE file + +$(call include,$(bld_root)/cxx/generic/configuration.make) + +# Make will try to build dependecies (since they are ultimately included +# files) during configuartion phase without cxx_generic being discovered +# yet. This is also why dependecies should be included with -include. +# +ifdef cxx_generic + +.PHONY: $(out_base)/%.o.d.$(cxx_s_suffix).clean + +$(out_base)/%.o.d.$(cxx_s_suffix).clean: + @: + +endif diff --git a/build/cxx/generic/cxx-o.make b/build/cxx/generic/cxx-o.make new file mode 100644 index 0000000..e88f5c6 --- /dev/null +++ b/build/cxx/generic/cxx-o.make @@ -0,0 +1,40 @@ +# file : build/cxx/generic/cxx-o.make +# author : Boris Kolpackov <boris@codesynthesis.com> +# copyright : Copyright (c) 2004-2010 Code Synthesis Tools CC +# license : GNU GPL v2; see accompanying LICENSE file + +$(call include-once,$(bld_root)/c/cpp-options.make,$(out_base)) +$(call include,$(bld_root)/cxx/generic/configuration.make) + +$(out_base)/%.o: cxx := $(cxx_generic) + +#@@ wrong prefix +# +$(out_base)/%.o: expand-cpp-options-impl = \ +$(if $1,$(shell sed -e 's%include: \(.*\)%\1%' -e t -e d $1)) + +$(out_base)/%.o: expand-cpp-options = \ +$(call expand-cpp-options-impl,$(filter %.cpp-options,$1)) + +ifeq ($(out_base),$(src_base)) +$(out_base)/%.o: $(src_base)/%.$(cxx_s_suffix) +else +$(out_base)/%.o: $(src_base)/%.$(cxx_s_suffix) | $$(dir $$@). +endif + $(call message,c++ $<,$(cxx) \ +$(cpp_options) $(call expand-cpp-options,$^) $(cxx_pp_extra_options) \ +$(cxx_options) $(cxx_pic_options) $(cxx_extra_options) -o $@ -c $<) + +ifneq ($(out_base),$(src_base)) + +$(out_base)/%.o: $(out_base)/%.$(cxx_s_suffix) | $$(dir $$@). + $(call message,c++ $<,$(cxx) \ +$(cpp_options) $(call expand-cpp-options,$^) $(cxx_pp_extra_options) \ +$(cxx_options) $(cxx_pic_options) $(cxx_extra_options) -o $@ -c $<) + +endif + +.PHONY: $(out_base)/%.o.$(cxx_s_suffix).clean + +$(out_base)/%.o.$(cxx_s_suffix).clean: + $(call message,rm $$1,rm -f $$1,$(basename $(basename $@))) diff --git a/build/cxx/generic/o-e.make b/build/cxx/generic/o-e.make new file mode 100644 index 0000000..8170da3 --- /dev/null +++ b/build/cxx/generic/o-e.make @@ -0,0 +1,28 @@ +# file : build/cxx/generic/o-e.make +# author : Boris Kolpackov <boris@codesynthesis.com> +# copyright : Copyright (c) 2004-2010 Code Synthesis Tools CC +# license : GNU GPL v2; see accompanying LICENSE file + +$(call include,$(bld_root)/cxx/generic/configuration.make) + +ifneq ($(cxx_extra_lib_paths),) +vpath %.so $(cxx_extra_lib_paths) +vpath %.a $(cxx_extra_lib_paths) +endif + +$(out_base)/%: ld := $(cxx_generic) +$(out_base)/%: expand-l = $(shell sed -e 's%^rpath:\(.*\)%%' $1) + +ifeq ($(out_base),$(src_base)) +$(out_base)/%: $(out_base)/%.o +else +$(out_base)/%: $(out_base)/%.o | $$(dir $$@). +endif + $(call message,ld $@,$(ld) \ +$(cxx_extra_options) $(ld_options) $(cxx_ld_extra_options) -o $@ \ +$(foreach f,$^,$(if $(patsubst %.l,,$f),$f,$(call expand-l,$f))) $(cxx_extra_libs)) + +.PHONY: $(out_base)/%.o.clean + +$(out_base)/%.o.clean: + $(call message,rm $(basename $(basename $@)),rm -f $(basename $@) $(basename $(basename $@))) diff --git a/build/cxx/generic/o-l.make b/build/cxx/generic/o-l.make new file mode 100644 index 0000000..5b29855 --- /dev/null +++ b/build/cxx/generic/o-l.make @@ -0,0 +1,67 @@ +# file : build/cxx/generic/o-l.make +# author : Boris Kolpackov <boris@codesynthesis.com> +# copyright : Copyright (c) 2004-2010 Code Synthesis Tools CC +# license : GNU GPL v2; see accompanying LICENSE file + +$(call include,$(bld_root)/cxx/generic/configuration.make) + +ifeq ($(ld_lib_type),shared) +$(call include,$(bld_root)/cxx/generic/configuration-sl.make) +endif + +ifneq ($(cxx_extra_lib_paths),) +vpath %.so $(cxx_extra_lib_paths) +vpath %.a $(cxx_extra_lib_paths) +endif + +ifdef ld_lib_type + +.PHONY: $(out_base)/%.l.o.clean + +ifeq ($(ld_lib_type),archive) + +$(out_base)/%.l: ar := $(ld_lib_ar) +$(out_base)/%.l: ar_options ?= -rc + +$(out_base)/%.l: ranlib := $(ld_lib_ranlib) +$(out_base)/%.l: ranlib_options ?= + +ifeq ($(out_base),$(src_base)) +$(out_base)/%.l: +else +$(out_base)/%.l: | $$(dir $$@). +endif + $(call message,ar $@,$(ar) $(ar_options) $(@D)/lib$(basename $(@F)).a $(filter %.o,$^)) + $(call message,,$(ranlib) $(ranlib_options) $(@D)/lib$(basename $(@F)).a) + $(call message,,echo "$(@D)/lib$(basename $(@F)).a" >$@) + $(call message,,echo "$(patsubst %.l,`cat %.l`,$(filter %.a %.so %.l,$^))" | xargs -n 1 echo >>$@) + +$(out_base)/%.l.o.clean: + $(call message,rm $$1,rm -f $$1 $(@D)/$(patsubst %.l.o.clean,lib%.a,$(@F)),$(basename $(basename $@))) + +else + +$(out_base)/%.l: ld := $(cxx_generic) +$(out_base)/%.l: c_pic_options := $(cxx_generic_pic_option) +$(out_base)/%.l: cxx_pic_options := $(cxx_generic_pic_option) +$(out_base)/%.l: comma_ := , + +$(out_base)/%.l: expand-l = $(shell sed -e 's%^rpath:\(.*\)%%' $1) + +ifeq ($(out_base),$(src_base)) +$(out_base)/%.l: +else +$(out_base)/%.l: | $$(dir $$@). +endif + $(call message,ld $@,$(ld) $(cxx_generic_shared_option) \ +$(cxx_extra_options) $(ld_options) $(cxx_ld_extra_options) -o $(@D)/lib$(basename $(@F)).so \ +$(foreach f,$^,$(if $(patsubst %.l,,$f),$f,$(call expand-l,$f))) $(cxx_extra_libs)) + $(call message,,echo "$(@D)/lib$(basename $(@F)).so" >$@) + $(call message,,echo "rpath:$(@D)" >>$@) + $(call message,,echo "$(patsubst %.l,`cat %.l`,$(filter %.a %.so %.l,$^))" | xargs -n 1 echo >>$@) + +$(out_base)/%.l.o.clean: + $(call message,rm $$1,rm -f $$1 $(@D)/$(patsubst %.l.o.clean,lib%.so,$(@F)),$(basename $(basename $@))) + +endif +endif diff --git a/build/cxx/gnu/configuration-rules.make b/build/cxx/gnu/configuration-rules.make new file mode 100644 index 0000000..7598be9 --- /dev/null +++ b/build/cxx/gnu/configuration-rules.make @@ -0,0 +1,15 @@ +# file : build/cxx/gnu/configuration-rules.make +# author : Boris Kolpackov <boris@codesynthesis.com> +# copyright : Copyright (c) 2004-2010 Code Synthesis Tools CC +# license : GNU GPL v2; see accompanying LICENSE file + +$(dcf_root)/cxx/gnu/configuration-dynamic.make: | $(dcf_root)/cxx/gnu/. + $(call message,,$(bld_root)/cxx/gnu/configure $@ $(cxx_optimize)) + +ifndef %foreign% + +disfigure:: + $(call message,rm $(dcf_root)/cxx/gnu/configuration-dynamic.make,\ +rm -f $(dcf_root)/cxx/gnu/configuration-dynamic.make) + +endif diff --git a/build/cxx/gnu/configuration-static.make b/build/cxx/gnu/configuration-static.make new file mode 100644 index 0000000..9a2521a --- /dev/null +++ b/build/cxx/gnu/configuration-static.make @@ -0,0 +1,4 @@ +# file : build/cxx/gnu/configuration-static.make +# author : Boris Kolpackov <boris@codesynthesis.com> +# copyright : Copyright (c) 2004-2010 Code Synthesis Tools CC +# license : GNU GPL v2; see accompanying LICENSE file diff --git a/build/cxx/gnu/configuration.make b/build/cxx/gnu/configuration.make new file mode 100644 index 0000000..57e00e9 --- /dev/null +++ b/build/cxx/gnu/configuration.make @@ -0,0 +1,34 @@ +# file : build/cxx/gnu/configuration.make +# author : Boris Kolpackov <boris@codesynthesis.com> +# copyright : Copyright (c) 2004-2010 Code Synthesis Tools CC +# license : GNU GPL v2; see accompanying LICENSE file + +$(call include-once,$(bld_root)/cxx/gnu/configuration-rules.make,$(dcf_root)) + +# Static configuration. +# +$(call include,$(bld_root)/cxx/gnu/configuration-static.make) + +ifneq ($(bld_root),$(scf_root)) +$(call -include,$(scf_root)/cxx/gnu/configuration-static.make) +endif + +# Dynamic configuration. +# +cxx_gnu := +cxx_gnu_optimization_options := + +$(call -include,$(dcf_root)/cxx/gnu/configuration-dynamic.make) + +ifdef cxx_gnu + +cxx_gnu_debugging_options := $(if $(findstring y,$(cxx_debug)),-g) + +$(out_root)/%: cxx_gnu_debugging_options := $(cxx_gnu_debugging_options) +$(out_root)/%: cxx_gnu_optimization_options := $(cxx_gnu_optimization_options) + +else + +.NOTPARALLEL: + +endif diff --git a/build/cxx/gnu/configure b/build/cxx/gnu/configure new file mode 100755 index 0000000..b9c6ef6 --- /dev/null +++ b/build/cxx/gnu/configure @@ -0,0 +1,55 @@ +#! /usr/bin/env bash + +# file : build/cxx/gnu/configure +# author : Boris Kolpackov <boris@codesynthesis.com> +# copyright : Copyright (c) 2004-2010 Code Synthesis Tools CC +# license : GNU GPL v2; see accompanying LICENSE file + +# $1 out file +# $2 optimize (y/n) +# +# bld_root - build root +# project_name - project name +# + + +source $bld_root/dialog.bash + +$echo +$echo +$echo "configuring '$project_name'" +$echo +$echo + +$echo +$echo "Please enter the g++ binary you would like to use, for example 'g++-3.4'," +$echo "'/usr/local/bin/g++' or 'distcc g++'." +$echo + +cxx_gnu=`read_path --command g++` +cxx_gnu_libraries=`$cxx_gnu -print-search-dirs | sed -e 's/libraries: =//p' -e d` + + +optimization= + +if [ "$2" == "y" ]; then + + $echo + $echo "Please select the optimization level you would like to use:" + $echo + $echo "(1) -O1 [Tries to reduce code size and execution time, without" + $echo " performing any optimizations that take a great deal of" + $echo " compilation time.]" + $echo "(2) -O2 [Performs nearly all supported optimizations that do not" + $echo " involve a space-speed tradeoff.]" + $echo "(3) -O3 [Optimize even more.]" + $echo "(4) -Os [Optimize for size.]" + $echo + + optimization=`read_option "-O1 -O2 -O3 -Os" "-O2"` + +fi + +echo "cxx_gnu := $cxx_gnu" > $1 +echo "cxx_gnu_libraries := $cxx_gnu_libraries" >> $1 +echo "cxx_gnu_optimization_options := $optimization" >> $1 diff --git a/build/cxx/gnu/cxx-d.make b/build/cxx/gnu/cxx-d.make new file mode 100644 index 0000000..642a846 --- /dev/null +++ b/build/cxx/gnu/cxx-d.make @@ -0,0 +1,59 @@ +# file : build/cxx/gnu/cxx-o.make +# author : Boris Kolpackov <boris@codesynthesis.com> +# copyright : Copyright (c) 2004-2010 Code Synthesis Tools CC +# license : GNU GPL v2; see accompanying LICENSE file + +$(call include-once,$(bld_root)/c/cpp-options.make,$(out_base)) +$(call include,$(bld_root)/cxx/gnu/configuration.make) + +# Make will try to build dependecies (since they are ultimately included +# files) during configuartion phase without cxx_gnu being discovered yet. +# This is also why dependecies should be included with -include. +# +ifdef cxx_gnu + +$(out_base)/%.o.d: cxx := $(cxx_gnu) +$(out_base)/%.o.d: cpp_options ?= + +#@@ This needs to be shared with cxx-o. +# +#@@ wrong prefix +# +$(out_base)/%.o.d: expand-cpp-options-impl = \ +$(if $1,$(shell sed -e 's%include: \(.*\)%\1%' -e t -e d $1)) + +$(out_base)/%.o.d: expand-cpp-options = \ +$(call expand-cpp-options-impl,$(filter %.cpp-options,$1)) + +.PRECIOUS: $(out_base)/%.o.d + +ifeq ($(out_base),$(src_base)) +$(out_base)/%.o.d: $(src_base)/%.$(cxx_s_suffix) +else +$(out_base)/%.o.d: $(src_base)/%.$(cxx_s_suffix) | $$(dir $$@). +endif + $(call message,,if test -f $@; then mv $@ $@.old; fi && \ +$(cxx) $(cpp_options) $(call expand-cpp-options,$^) $(cxx_pp_extra_options) \ +$(cxx_extra_options) -M -MG -MP -MQ $@ -MQ $(basename $@) $< | \ +$(bld_root)/c/gnu/dep $(out_base) $(filter %.cpp-options,$^) >$@ && \ +if test -f $@.old; then if cmp -s $@ $@.old; then rm -f $@.old && false; \ +else rm -f $@.old && true; fi fi) + +ifneq ($(out_base),$(src_base)) + +$(out_base)/%.o.d: $(out_base)/%.$(cxx_s_suffix) | $$(dir $$@). + $(call message,,if test -f $@; then mv $@ $@.old; fi && \ +$(cxx) $(cpp_options) $(call expand-cpp-options,$^) $(cxx_pp_extra_options) \ +$(cxx_extra_options) -M -MG -MP -MQ $@ -MQ $(basename $@) $< | \ +$(bld_root)/c/gnu/dep $(out_base) $(filter %.cpp-options,$^) >$@ && \ +if test -f $@.old; then if cmp -s $@ $@.old; then rm -f $@.old && false; \ +else rm -f $@.old && true; fi fi) + +endif + +.PHONY: $(out_base)/%.o.d.$(cxx_s_suffix).clean + +$(out_base)/%.o.d.$(cxx_s_suffix).clean: + $(call message,rm $$1,rm -f $$1,$(basename $(basename $@))) + +endif diff --git a/build/cxx/gnu/cxx-o.make b/build/cxx/gnu/cxx-o.make new file mode 100644 index 0000000..0320177 --- /dev/null +++ b/build/cxx/gnu/cxx-o.make @@ -0,0 +1,41 @@ +# file : build/cxx/gnu/cxx-o.make +# author : Boris Kolpackov <boris@codesynthesis.com> +# copyright : Copyright (c) 2004-2010 Code Synthesis Tools CC +# license : GNU GPL v2; see accompanying LICENSE file + +$(call include-once,$(bld_root)/c/cpp-options.make,$(out_base)) +$(call include,$(bld_root)/cxx/gnu/configuration.make) + +$(out_base)/%.o: cxx := $(cxx_gnu) +$(out_base)/%.o: cxx_options := $(cxx_gnu_optimization_options) $(cxx_gnu_debugging_options) + +#@@ wrong prefix +# +$(out_base)/%.o: expand-cpp-options-impl = \ +$(if $1,$(shell sed -e 's%include: \(.*\)%\1%' -e t -e d $1)) + +$(out_base)/%.o: expand-cpp-options = \ +$(call expand-cpp-options-impl,$(filter %.cpp-options,$1)) + +ifeq ($(out_base),$(src_base)) +$(out_base)/%.o: $(src_base)/%.$(cxx_s_suffix) +else +$(out_base)/%.o: $(src_base)/%.$(cxx_s_suffix) | $$(dir $$@). +endif + $(call message,c++ $<,$(cxx) \ +$(cpp_options) $(call expand-cpp-options,$^) $(cxx_pp_extra_options) \ +$(cxx_options) $(cxx_pic_options) $(cxx_extra_options) -o $@ -c $<) + +ifneq ($(out_base),$(src_base)) + +$(out_base)/%.o: $(out_base)/%.$(cxx_s_suffix) | $$(dir $$@). + $(call message,c++ $<,$(cxx) \ +$(cpp_options) $(call expand-cpp-options,$^) $(cxx_pp_extra_options) \ +$(cxx_options) $(cxx_pic_options) $(cxx_extra_options) -o $@ -c $<) + +endif + +.PHONY: $(out_base)/%.o.$(cxx_s_suffix).clean + +$(out_base)/%.o.$(cxx_s_suffix).clean: + $(call message,rm $$1,rm -f $$1,$(basename $(basename $@))) diff --git a/build/cxx/gnu/o-e.make b/build/cxx/gnu/o-e.make new file mode 100644 index 0000000..8c233bd --- /dev/null +++ b/build/cxx/gnu/o-e.make @@ -0,0 +1,39 @@ +# file : build/cxx/gnu/o-e.make +# author : Boris Kolpackov <boris@codesynthesis.com> +# copyright : Copyright (c) 2004-2010 Code Synthesis Tools CC +# license : GNU GPL v2; see accompanying LICENSE file + +$(call include,$(bld_root)/cxx/gnu/configuration.make) + +#@@ should it be lib%.so? +# +ifneq ($(cxx_extra_lib_paths),) +vpath %.so $(cxx_extra_lib_paths) +vpath %.a $(cxx_extra_lib_paths) +endif + +ifneq ($(cxx_gnu_libraries),) +vpath %.so $(cxx_gnu_libraries) +vpath %.a $(cxx_gnu_libraries) +endif + +$(out_base)/%: ld := $(cxx_gnu) +$(out_base)/%: ld_options := $(cxx_gnu_optimization_options) $(cxx_gnu_debugging_options) $(cxx_ld_extra_options) + +$(out_base)/%: expand-l = $(if $(subst n,,$(cxx_rpath)),\ +$(shell sed -e 's%^rpath:\(.*\)%-Wl,-rpath,\1%' $1),\ +$(shell sed -e 's%^rpath:\(.*\)%%' $1)) + +ifeq ($(out_base),$(src_base)) +$(out_base)/%: $(out_base)/%.o +else +$(out_base)/%: $(out_base)/%.o | $$(dir $$@). +endif + $(call message,ld $@,$(ld) \ +$(cxx_extra_options) $(ld_options) $(cxx_ld_extra_options) -o $@ \ +$(foreach f,$^,$(if $(patsubst %.l,,$f),$f,$(call expand-l,$f))) $(cxx_extra_libs)) + +.PHONY: $(out_base)/%.o.clean + +$(out_base)/%.o.clean: + $(call message,rm $(basename $(basename $@)),rm -f $(basename $@) $(basename $(basename $@))) diff --git a/build/cxx/gnu/o-l.make b/build/cxx/gnu/o-l.make new file mode 100644 index 0000000..e378a4d --- /dev/null +++ b/build/cxx/gnu/o-l.make @@ -0,0 +1,72 @@ +# file : build/cxx/gnu/o-l.make +# author : Boris Kolpackov <boris@codesynthesis.com> +# copyright : Copyright (c) 2004-2010 Code Synthesis Tools CC +# license : GNU GPL v2; see accompanying LICENSE file + +$(call include,$(bld_root)/cxx/gnu/configuration.make) + +ifneq ($(cxx_extra_lib_paths),) +vpath %.so $(cxx_extra_lib_paths) +vpath %.a $(cxx_extra_lib_paths) +endif + +ifneq ($(cxx_gnu_libraries),) +vpath %.so $(cxx_gnu_libraries) +vpath %.a $(cxx_gnu_libraries) +endif + +ifdef ld_lib_type + +.PHONY: $(out_base)/%.l.o.clean + +ifeq ($(ld_lib_type),archive) + +$(out_base)/%.l: ar := $(ld_lib_ar) +$(out_base)/%.l: ar_options ?= -rc + +$(out_base)/%.l: ranlib := $(ld_lib_ranlib) +$(out_base)/%.l: ranlib_options ?= + +ifeq ($(out_base),$(src_base)) +$(out_base)/%.l: +else +$(out_base)/%.l: | $$(dir $$@). +endif + $(call message,ar $@,$(ar) $(ar_options) $(@D)/lib$(basename $(@F)).a $(filter %.o,$^)) + $(call message,,$(ranlib) $(ranlib_options) $(@D)/lib$(basename $(@F)).a) + $(call message,,echo "$(@D)/lib$(basename $(@F)).a" >$@) + $(call message,,echo "$(patsubst %.l,`cat %.l`,$(filter %.a %.so %.l,$^))" | xargs -n 1 echo >>$@) + +$(out_base)/%.l.o.clean: + $(call message,rm $$1,rm -f $$1 $(@D)/$(patsubst %.l.o.clean,lib%.a,$(@F)),$(basename $(basename $@))) + +else + +$(out_base)/%.l: ld := $(cxx_gnu) +$(out_base)/%.l: ld_options := $(cxx_gnu_optimization_options) $(cxx_gnu_debugging_options) +$(out_base)/%.l: c_pic_options := -fPIC +$(out_base)/%.l: cxx_pic_options := -fPIC +$(out_base)/%.l: comma_ := , + +$(out_base)/%.l: expand-l = $(if $(subst n,,$(cxx_rpath)),\ +$(shell sed -e 's%^rpath:\(.*\)%-Wl,-rpath,\1%' $1),\ +$(shell sed -e 's%^rpath:\(.*\)%%' $1)) + +ifeq ($(out_base),$(src_base)) +$(out_base)/%.l: +else +$(out_base)/%.l: | $$(dir $$@). +endif + $(call message,ld $@,$(ld) -shared \ +$(cxx_extra_options) $(ld_options) $(cxx_ld_extra_options) \ +-o $(@D)/lib$(basename $(@F)).so -Wl$(comma_)-soname=lib$(basename $(@F)).so \ +$(foreach f,$^,$(if $(patsubst %.l,,$f),$f,$(call expand-l,$f))) $(cxx_extra_libs)) + $(call message,,echo "$(@D)/lib$(basename $(@F)).so" >$@) + $(call message,,echo "rpath:$(@D)" >>$@) + $(call message,,echo "$(patsubst %.l,`cat %.l`,$(filter %.a %.so %.l,$^))" | xargs -n 1 echo >>$@) + +$(out_base)/%.l.o.clean: + $(call message,rm $$1,rm -f $$1 $(@D)/$(patsubst %.l.o.clean,lib%.so,$(@F)),$(basename $(basename $@))) + +endif +endif diff --git a/build/cxx/intel/configuration-rules.make b/build/cxx/intel/configuration-rules.make new file mode 100644 index 0000000..577f2f7 --- /dev/null +++ b/build/cxx/intel/configuration-rules.make @@ -0,0 +1,15 @@ +# file : build/cxx/intel/configuration-rules.make +# author : Boris Kolpackov <boris@codesynthesis.com> +# copyright : Copyright (c) 2004-2010 Code Synthesis Tools CC +# license : GNU GPL v2; see accompanying LICENSE file + +$(dcf_root)/cxx/intel/configuration-dynamic.make: | $(dcf_root)/cxx/intel/. + $(call message,,$(bld_root)/cxx/intel/configure $@ $(cxx_optimize)) + +ifndef %foreign% + +disfigure:: + $(call message,rm $(dcf_root)/cxx/intel/configuration-dynamic.make,\ +rm -f $(dcf_root)/cxx/intel/configuration-dynamic.make) + +endif diff --git a/build/cxx/intel/configuration-static.make b/build/cxx/intel/configuration-static.make new file mode 100644 index 0000000..e619365 --- /dev/null +++ b/build/cxx/intel/configuration-static.make @@ -0,0 +1,4 @@ +# file : build/cxx/intel/configuration-static.make +# author : Boris Kolpackov <boris@codesynthesis.com> +# copyright : Copyright (c) 2004-2010 Code Synthesis Tools CC +# license : GNU GPL v2; see accompanying LICENSE file diff --git a/build/cxx/intel/configuration.make b/build/cxx/intel/configuration.make new file mode 100644 index 0000000..eade065 --- /dev/null +++ b/build/cxx/intel/configuration.make @@ -0,0 +1,34 @@ +# file : build/cxx/intel/configuration.make +# author : Boris Kolpackov <boris@codesynthesis.com> +# copyright : Copyright (c) 2004-2010 Code Synthesis Tools CC +# license : GNU GPL v2; see accompanying LICENSE file + +$(call include-once,$(bld_root)/cxx/intel/configuration-rules.make,$(dcf_root)) + +# Static configuration. +# +$(call include,$(bld_root)/cxx/intel/configuration-static.make) + +ifneq ($(bld_root),$(scf_root)) +$(call -include,$(scf_root)/cxx/intel/configuration-static.make) +endif + +# Dynamic configuration. +# +cxx_intel := +cxx_intel_optimization_options := + +$(call -include,$(dcf_root)/cxx/intel/configuration-dynamic.make) + +ifdef cxx_intel + +cxx_intel_debugging_options := $(if $(findstring y,$(cxx_debug)),-g) + +$(out_root)/%: cxx_intel_debugging_options := $(cxx_intel_debugging_options) +$(out_root)/%: cxx_intel_optimization_options := $(cxx_intel_optimization_options) + +else + +.NOTPARALLEL: + +endif diff --git a/build/cxx/intel/configure b/build/cxx/intel/configure new file mode 100755 index 0000000..ef250cf --- /dev/null +++ b/build/cxx/intel/configure @@ -0,0 +1,52 @@ +#! /usr/bin/env bash + +# file : build/cxx/intel/configure +# author : Boris Kolpackov <boris@codesynthesis.com> +# copyright : Copyright (c) 2004-2010 Code Synthesis Tools CC +# license : GNU GPL v2; see accompanying LICENSE file + +# $1 out file +# $2 optimize (y/n) +# +# bld_root - build root +# project_name - project name +# + + +source $bld_root/dialog.bash + +$echo +$echo +$echo "configuring '$project_name'" +$echo +$echo + +$echo +$echo "Please enter the icc binary you would like to use, for example " +$echo "'/opt/intel_cc_80/bin/icpc'." +$echo + +cxx_intel=`read_path --command icpc` +cxx_intel_libraries=`$cxx_intel -print-search-dirs | sed -e 's/libraries: =//p' -e d` + +# Intel optimizes by default. +# +optimization=-O0 + +if [ "$2" == "y" ]; then + + $echo + $echo "Please select the optimization level you would like to use:" + $echo + $echo "(1) -O1 [Enable optimizations.]" + $echo "(2) -O2 [Same as -O1.]" + $echo "(3) -O3 [As -O2 plus more aggressive optimizations that may not" + $echo " improve performance for all programs.]" + $echo + + optimization=`read_option "-O1 -O2 -O3" "-O2"` +fi + +echo "cxx_intel := $cxx_intel" > $1 +echo "cxx_intel_libraries := $cxx_intel_libraries" >> $1 +echo "cxx_intel_optimization_options := $optimization" >> $1 diff --git a/build/cxx/intel/cxx-d.make b/build/cxx/intel/cxx-d.make new file mode 100644 index 0000000..cd7b567 --- /dev/null +++ b/build/cxx/intel/cxx-d.make @@ -0,0 +1,59 @@ +# file : build/cxx/intel/cxx-o.make +# author : Boris Kolpackov <boris@codesynthesis.com> +# copyright : Copyright (c) 2004-2010 Code Synthesis Tools CC +# license : GNU GPL v2; see accompanying LICENSE file + +$(call include-once,$(bld_root)/c/cpp-options.make,$(out_base)) +$(call include,$(bld_root)/cxx/intel/configuration.make) + +# Make will try to build dependecies (since they are ultimately included +# files) during configuartion phase without cxx_intel being discovered yet. +# This is also why dependecies should be included with -include. +# +ifdef cxx_intel + +$(out_base)/%.o.d: cxx := $(cxx_intel) +$(out_base)/%.o.d: cpp_options ?= + +#@@ This needs to be shared with cxx-o. +# +#@@ wrong prefix +# +$(out_base)/%.o.d: expand-cpp-options-impl = \ +$(if $1,$(shell sed -e 's%include: \(.*\)%\1%' -e t -e d $1)) + +$(out_base)/%.o.d: expand-cpp-options = \ +$(call expand-cpp-options-impl,$(filter %.cpp-options,$1)) + +.PRECIOUS: $(out_base)/%.o.d + +ifeq ($(out_base),$(src_base)) +$(out_base)/%.o.d: $(src_base)/%.$(cxx_s_suffix) +else +$(out_base)/%.o.d: $(src_base)/%.$(cxx_s_suffix) | $$(dir $$@). +endif + $(call message,,if test -f $@; then mv $@ $@.old; fi && \ +$(cxx) $(cpp_options) $(call expand-cpp-options,$^) $(cxx_pp_extra_options) \ +$(cxx_extra_options) -M -MG -MP -MQ $@ -MQ $(basename $@) $< | \ +$(bld_root)/c/intel/dep $(out_base) $(filter %.cpp-options,$^) >$@ && \ +if test -f $@.old; then if cmp -s $@ $@.old; then rm -f $@.old && false; \ +else rm -f $@.old && true; fi fi) + +ifneq ($(out_base),$(src_base)) + +$(out_base)/%.o.d: $(out_base)/%.$(cxx_s_suffix) | $$(dir $$@). + $(call message,,if test -f $@; then mv $@ $@.old; fi && \ +$(cxx) $(cpp_options) $(call expand-cpp-options,$^) $(cxx_pp_extra_options) \ +$(cxx_extra_options) -M -MG -MP -MQ $@ -MQ $(basename $@) $< | \ +$(bld_root)/c/intel/dep $(out_base) $(filter %.cpp-options,$^) >$@ && \ +if test -f $@.old; then if cmp -s $@ $@.old; then rm -f $@.old && false; \ +else rm -f $@.old && true; fi fi) + +endif + +.PHONY: $(out_base)/%.o.d.$(cxx_s_suffix).clean + +$(out_base)/%.o.d.$(cxx_s_suffix).clean: + $(call message,rm $$1,rm -f $$1,$(basename $(basename $@))) + +endif diff --git a/build/cxx/intel/cxx-o.make b/build/cxx/intel/cxx-o.make new file mode 100644 index 0000000..c64e2c8 --- /dev/null +++ b/build/cxx/intel/cxx-o.make @@ -0,0 +1,41 @@ +# file : build/cxx/intel/cxx-o.make +# author : Boris Kolpackov <boris@codesynthesis.com> +# copyright : Copyright (c) 2004-2010 Code Synthesis Tools CC +# license : GNU GPL v2; see accompanying LICENSE file + +$(call include-once,$(bld_root)/c/cpp-options.make,$(out_base)) +$(call include,$(bld_root)/cxx/intel/configuration.make) + +$(out_base)/%.o: cxx := $(cxx_intel) +$(out_base)/%.o: cxx_options := $(cxx_intel_optimization_options) $(cxx_intel_debugging_options) + +#@@ wrong prefix +# +$(out_base)/%.o: expand-cpp-options-impl = \ +$(if $1,$(shell sed -e 's%include: \(.*\)%\1%' -e t -e d $1)) + +$(out_base)/%.o: expand-cpp-options = \ +$(call expand-cpp-options-impl,$(filter %.cpp-options,$1)) + +ifeq ($(out_base),$(src_base)) +$(out_base)/%.o: $(src_base)/%.$(cxx_s_suffix) +else +$(out_base)/%.o: $(src_base)/%.$(cxx_s_suffix) | $$(dir $$@). +endif + $(call message,c++ $<,$(cxx) \ +$(cpp_options) $(call expand-cpp-options,$^) $(cxx_pp_extra_options) \ +$(cxx_options) $(cxx_pic_options) $(cxx_extra_options) -o $@ -c $<) + +ifneq ($(out_base),$(src_base)) + +$(out_base)/%.o: $(out_base)/%.$(cxx_s_suffix) | $$(dir $$@). + $(call message,c++ $<,$(cxx) \ +$(cpp_options) $(call expand-cpp-options,$^) $(cxx_pp_extra_options) \ +$(cxx_options) $(cxx_pic_options) $(cxx_extra_options) -o $@ -c $<) + +endif + +.PHONY: $(out_base)/%.o.$(cxx_s_suffix).clean + +$(out_base)/%.o.$(cxx_s_suffix).clean: + $(call message,rm $$1,rm -f $$1,$(basename $(basename $@))) diff --git a/build/cxx/intel/o-e.make b/build/cxx/intel/o-e.make new file mode 100644 index 0000000..c92173a --- /dev/null +++ b/build/cxx/intel/o-e.make @@ -0,0 +1,39 @@ +# file : build/cxx/intel/o-e.make +# author : Boris Kolpackov <boris@codesynthesis.com> +# copyright : Copyright (c) 2004-2010 Code Synthesis Tools CC +# license : GNU GPL v2; see accompanying LICENSE file + +$(call include,$(bld_root)/cxx/intel/configuration.make) + +#@@ should it be lib%.so? +# +ifneq ($(cxx_extra_lib_paths),) +vpath %.so $(cxx_extra_lib_paths) +vpath %.a $(cxx_extra_lib_paths) +endif + +ifneq ($(cxx_intel_libraries),) +vpath %.so $(cxx_intel_libraries) +vpath %.a $(cxx_intel_libraries) +endif + +$(out_base)/%: ld := $(cxx_intel) +$(out_base)/%: ld_options := $(cxx_intel_optimization_options) $(cxx_intel_debugging_options) $(cxx_ld_extra_options) + +$(out_base)/%: expand-l = $(if $(subst n,,$(cxx_rpath)),\ +$(shell sed -e 's%^rpath:\(.*\)%-Wl,-rpath,\1%' $1),\ +$(shell sed -e 's%^rpath:\(.*\)%%' $1)) + +ifeq ($(out_base),$(src_base)) +$(out_base)/%: $(out_base)/%.o +else +$(out_base)/%: $(out_base)/%.o | $$(dir $$@). +endif + $(call message,ld $@,$(ld) \ +$(cxx_extra_options) $(ld_options) $(cxx_ld_extra_options) -o $@ \ +$(foreach f,$^,$(if $(patsubst %.l,,$f),$f,$(call expand-l,$f))) $(cxx_extra_libs)) + +.PHONY: $(out_base)/%.o.clean + +$(out_base)/%.o.clean: + $(call message,rm $(basename $(basename $@)),rm -f $(basename $@) $(basename $(basename $@))) diff --git a/build/cxx/intel/o-l.make b/build/cxx/intel/o-l.make new file mode 100644 index 0000000..76f8cff --- /dev/null +++ b/build/cxx/intel/o-l.make @@ -0,0 +1,72 @@ +# file : build/cxx/intel/o-l.make +# author : Boris Kolpackov <boris@codesynthesis.com> +# copyright : Copyright (c) 2004-2010 Code Synthesis Tools CC +# license : GNU GPL v2; see accompanying LICENSE file + +$(call include,$(bld_root)/cxx/intel/configuration.make) + +ifneq ($(cxx_extra_lib_paths),) +vpath %.so $(cxx_extra_lib_paths) +vpath %.a $(cxx_extra_lib_paths) +endif + +ifneq ($(cxx_intel_libraries),) +vpath %.so $(cxx_intel_libraries) +vpath %.a $(cxx_intel_libraries) +endif + +ifdef ld_lib_type + +.PHONY: $(out_base)/%.l.o.clean + +ifeq ($(ld_lib_type),archive) + +$(out_base)/%.l: ar := $(ld_lib_ar) +$(out_base)/%.l: ar_options ?= -rc + +$(out_base)/%.l: ranlib := $(ld_lib_ranlib) +$(out_base)/%.l: ranlib_options ?= + +ifeq ($(out_base),$(src_base)) +$(out_base)/%.l: +else +$(out_base)/%.l: | $$(dir $$@). +endif + $(call message,ar $@,$(ar) $(ar_options) $(@D)/lib$(basename $(@F)).a $(filter %.o,$^)) + $(call message,,$(ranlib) $(ranlib_options) $(@D)/lib$(basename $(@F)).a) + $(call message,,echo "$(@D)/lib$(basename $(@F)).a" >$@) + $(call message,,echo "$(patsubst %.l,`cat %.l`,$(filter %.a %.so %.l,$^))" | xargs -n 1 echo >>$@) + +$(out_base)/%.l.o.clean: + $(call message,rm $$1,rm -f $$1 $(@D)/$(patsubst %.l.o.clean,lib%.a,$(@F)),$(basename $(basename $@))) + +else + +$(out_base)/%.l: ld := $(cxx_intel) +$(out_base)/%.l: ld_options := $(cxx_intel_optimization_options) $(cxx_intel_debugging_options) +$(out_base)/%.l: c_pic_options := -fPIC +$(out_base)/%.l: cxx_pic_options := -fPIC +$(out_base)/%.l: comma_ := , + +$(out_base)/%.l: expand-l = $(if $(subst n,,$(cxx_rpath)),\ +$(shell sed -e 's%^rpath:\(.*\)%-Wl,-rpath,\1%' $1),\ +$(shell sed -e 's%^rpath:\(.*\)%%' $1)) + +ifeq ($(out_base),$(src_base)) +$(out_base)/%.l: +else +$(out_base)/%.l: | $$(dir $$@). +endif + $(call message,ld $@,$(ld) -shared \ +$(cxx_extra_options) $(ld_options) $(cxx_ld_extra_options) \ +-o $(@D)/lib$(basename $(@F)).so -Wl$(comma_)-soname=lib$(basename $(@F)).so \ +$(foreach f,$^,$(if $(patsubst %.l,,$f),$f,$(call expand-l,$f))) $(cxx_extra_libs)) + $(call message,,echo "$(@D)/lib$(basename $(@F)).so" >$@) + $(call message,,echo "rpath:$(@D)" >>$@) + $(call message,,echo "$(patsubst %.l,`cat %.l`,$(filter %.a %.so %.l,$^))" | xargs -n 1 echo >>$@) + +$(out_base)/%.l.o.clean: + $(call message,rm $$1,rm -f $$1 $(@D)/$(patsubst %.l.o.clean,lib%.so,$(@F)),$(basename $(basename $@))) + +endif +endif diff --git a/build/cxx/o-e.make b/build/cxx/o-e.make new file mode 100644 index 0000000..55486b3 --- /dev/null +++ b/build/cxx/o-e.make @@ -0,0 +1,10 @@ +# file : build/cxx/o-e.make +# author : Boris Kolpackov <boris@codesynthesis.com> +# copyright : Copyright (c) 2004-2010 Code Synthesis Tools CC +# license : GNU GPL v2; see accompanying LICENSE file + +$(call include,$(bld_root)/cxx/configuration.make) + +ifdef cxx_id +$(call include-once,$(bld_root)/cxx/$(cxx_id)/o-e.make,$(out_base)) +endif diff --git a/build/cxx/o-l.make b/build/cxx/o-l.make new file mode 100644 index 0000000..5eb04d4 --- /dev/null +++ b/build/cxx/o-l.make @@ -0,0 +1,11 @@ +# file : build/cxx/o-l.make +# author : Boris Kolpackov <boris@codesynthesis.com> +# copyright : Copyright (c) 2004-2010 Code Synthesis Tools CC +# license : GNU GPL v2; see accompanying LICENSE file + +$(call include,$(bld_root)/ld/configuration-lib.make) +$(call include,$(bld_root)/cxx/configuration.make) + +ifdef cxx_id +$(call include-once,$(bld_root)/cxx/$(cxx_id)/o-l.make,$(out_base)) +endif diff --git a/build/dialog.bash b/build/dialog.bash new file mode 100644 index 0000000..17cced0 --- /dev/null +++ b/build/dialog.bash @@ -0,0 +1,249 @@ +# file : build/dialog.bash +# author : Boris Kolpackov <boris@codesynthesis.com> +# copyright : Copyright (c) 2004-2010 Code Synthesis Tools CC +# license : GNU GPL v2; see accompanying LICENSE file + +# bld_root - build root +# MAKE - GNU make executable +# + +#@@ can't I do exec 1>&2 or something? +# +function echo_error () +{ + echo "$*" 1>&2 +} + +echo=echo_error + +function abspath_old () +{ + local r=`eval echo $1` # for tilde-expansion + + if [ "`echo $r | sed -e 's%^/.*$%%'`" ]; then + + r=`pwd`/$r + fi + + # remove trailing `/' + # + r=`echo $r | sed -e 's%^\(.\+\)/$%\1%'` + + echo $r +} + +# Get rid of jobserver info. See GNU make bug #12229. +# +MAKEFLAGS=`echo $MAKEFLAGS | sed -e 's/--jobserver-fds=[^ ]* *//g'` +MAKEFLAGS=`echo $MAKEFLAGS | sed -e 's/-j *//g'` + + +function abspath () +{ + local r=`eval echo $1` # for tilde-expansion + + $MAKE --no-print-directory -f $bld_root/abspath.make $r +} + +# $1 Default answer ('y' or 'n'). [optional] +# +function read_y_n () +{ + local r + + while [ -z "$r" ]; do + + read -p "[$1]: " r + + if [ -z "$r" ]; then + r=$1 + fi + + case "$r" in + y) ;; + n) ;; + *) r= ;; + esac + done + + echo $r +} + +# $1 Default answer. [optional] +# +function read_value () +{ + local r + + read -p "[$1]: " r + + if [ -z "$r" ]; then + r=$1 + fi + + echo $r +} + +# $1 Space-separated list of options. +# $2 Default answer from the list of options. [optional] +# +function read_option () +{ + local d o r i + + if [ "$2" ]; then + + d=1 + + for o in $1; do + + if [ "$o" = "$2" ]; then break; fi + + d=$(($d + 1)) + done + fi + + while [ -z "$r" ]; do + + read -p "[$d]: " r + + if [ -z "$r" ]; then + + r=$d + fi + + i=1 + + for o in $1; do + + if [ "$i" = "$r" ]; then + + echo $o + return 0 + fi + + i=$(($i + 1)) + done + + # User must have entered some junk so let's ask her again. + # + r= + done +} + + +# $1 Default answer. [optional] +# +# --command - path to be read is a command (implies --exist) +# +# --directory - path to be read is a directory +# +# --exist - path to be read should exist +# +# +function read_path () +{ + local command=0 + local directory=0 + local exist=0 + + # Parse options + # + while [ "$1" ]; do + case $1 in + + --command) + + command=1 + exist=1 + shift + ;; + + --directory) + + directory=1 + shift + ;; + + --exist) + + exist=1 + shift + ;; + + *) + + break + ;; + + esac + done + + local r tmp + + while [ -z "$r" ]; do + + read -e -p "[$1]: " r + + if [ -z "$r" ]; then + + r=$1 + fi + + if [ -z "$r" ]; then + + continue + fi + + + if [ $command == 1 ]; then + + # Do tilde expansion. + # + r=`eval echo $r` + + # Extract first word. + # + local cmd=`echo $r | cut -d " " -f 1` + + type -p $cmd 1>/dev/null 2>&1 + + if [ $? != 0 ]; then + + $echo "$r: command not found" + r= + + fi + + continue + fi + + # abspath & checks + # + r=`abspath $r` + + if [ $exist == 1 ]; then + + if [ $directory == 1 ]; then + + if [ ! -d "$r" ]; then + + $echo "$r: no such directory" + r= + continue + fi + + else # something else + + if [ ! -e "$r" ]; then + + $echo "$r: no such file or directory" + r= + continue + fi + fi + fi + done + + echo $r +} diff --git a/build/dir.make b/build/dir.make new file mode 100644 index 0000000..32227b5 --- /dev/null +++ b/build/dir.make @@ -0,0 +1,9 @@ +# file : build/dir.make +# author : Boris Kolpackov <boris@codesynthesis.com> +# copyright : Copyright (c) 2004-2010 Code Synthesis Tools CC +# license : GNU GPL v2; see accompanying LICENSE file + +.PRECIOUS: %/. + +%/. : + $(call message,,mkdir -p $*) diff --git a/build/frame.make b/build/frame.make new file mode 100644 index 0000000..bb1526c --- /dev/null +++ b/build/frame.make @@ -0,0 +1,104 @@ +# file : build/frame.make +# author : Boris Kolpackov <boris@codesynthesis.com> +# copyright : Copyright (c) 2004-2010 Code Synthesis Tools CC +# license : GNU GPL v2; see accompanying LICENSE file + +%frame_exclude% += CURDIR SHELL MAKEFILE_LIST MAKEFLAGS +%frame_include% := #.DEFAULT_GOAL - for some reason it is already in the list + + +# return only vars with 'file' origin +# +%frame_exclude% += frame-vars-stage +define frame-vars-stage +$(foreach v,$1,$(if $(findstring file,$(origin $v)),$v)) +endef + + +# $1 holds exclusion list +# +%frame_exclude% += frame-vars +define frame-vars +$(call frame-vars-stage,$(filter-out \%% $(%frame_exclude%) $1,$(.VARIABLES))) \ +$(filter-out $1,$(%frame_include%)) +endef + + +%frame% := frame% + + +%frame_exclude% += frame-set-recursive +define frame-set-recursive +define $1 +$2 +endef +endef + +%frame_exclude% += frame-undefine +ifneq ($(filter undefine,$(.FEATURES)),) +define frame-undefine +$(eval undefine $$1) +endef +define frame-undefine-imm +$(eval undefine $1) +endef +else +define frame-undefine +$(eval $$1 :=) +endef +define frame-undefine-imm +$(eval $1 :=) +endef +endif + +%frame_exclude% += frame-save +define frame-save +$(eval $(if $(filter simple,$(flavor $1)),\ +%$1/$(%frame%) := $(value $1),\ +$(call frame-set-recursive,%$1/$(%frame%),$(value $1)))) +endef + +%frame_exclude% += frame-restore +define frame-restore +$(eval $(if $(filter simple,$(flavor %$1/$(%frame%))),\ +$1 := $(value %$1/$(%frame%)),\ +$(call frame-set-recursive,$1,$(value %$1/$(%frame%)))))\ +$(call frame-undefine-imm,%$1/$(%frame%)) +endef + +# Use debug messages to check for garbage being framed. +# + +#$$(warning framing $$(value %vars_$(%frame%))) + +%frame_exclude% += frame-enter-body +define frame-enter-body +%vars_$(%frame%) := $(call frame-vars,$1) +%excl_$(%frame%) := $1 +$$(foreach v,$$(value %vars_$(%frame%)),$$(call frame-save,$$v)) +%frame% := frame/$(%frame%) +endef + +%frame_exclude% += frame-enter +define frame-enter +$(eval $(call frame-enter-body,$1)) +endef + + +#$$(warning restoring $$(value %vars_$$(%frame%))) + +%frame_exclude% += frame-leave-body +define frame-leave-body +%frame% := $(patsubst frame/%,%,$(%frame%)) +$$(foreach v,$$(value %vars_$$(%frame%)),$$(call frame-restore,$$v)) +$$(foreach v,\ +$$(filter-out $$(value %vars_$$(%frame%)),$$(call frame-vars,$$(value %excl_$$(%frame%)))),\ +$$(call frame-undefine,$$v)) +$$(call frame-undefine,%vars_$$(%frame%)) +$$(call frame-undefine,%excl_$$(%frame%)) +endef + +%frame_exclude% += frame-leave +define frame-leave +$(eval $(call frame-leave-body)) +endef diff --git a/build/git/gitignore b/build/git/gitignore new file mode 100755 index 0000000..a8828d7 --- /dev/null +++ b/build/git/gitignore @@ -0,0 +1,13 @@ +#! /usr/bin/env bash + +# file : build/git/gitignore +# author : Boris Kolpackov <boris@codesynthesis.com> +# copyright : Copyright (c) 2004-2010 Code Synthesis Tools CC +# license : GNU GPL v2; see accompanying LICENSE file + +echo '# Generated .gitignore file; do not edit or version control.' +echo '#' + +for f in "$@"; do +echo $f +done diff --git a/build/git/gitignore.make b/build/git/gitignore.make new file mode 100644 index 0000000..c42467a --- /dev/null +++ b/build/git/gitignore.make @@ -0,0 +1,11 @@ +# file : build/git/gitignore.make +# author : Boris Kolpackov <boris@codesynthesis.com> +# copyright : Copyright (c) 2004-2010 Code Synthesis Tools CC +# license : GNU GPL v2; see accompanying LICENSE file + +$(out_base)/.gitignore: + @$(bld_root)/git/gitignore $(files) >$@ + +.PHONY: $(out_base)/.gitignore.clean +$(out_base)/.gitignore.clean: + @rm -f $(basename $@) diff --git a/build/import.make b/build/import.make new file mode 100644 index 0000000..122aee0 --- /dev/null +++ b/build/import.make @@ -0,0 +1,75 @@ +# file : build/import.make +# author : Boris Kolpackov <boris@codesynthesis.com> +# copyright : Copyright (c) 2004-2010 Code Synthesis Tools CC +# license : GNU GPL v2; see accompanying LICENSE file + + +# This cannot be eliminated. +# +%frame_exclude% += import-set-value +define import-set-value +$(eval $$1 := $$2) +endef + +%frame_exclude% += exported-names +define exported-names +$(foreach i,1 2 3 4 5 6 7,$(if $(value $i),$(lastword $(value $i)))) +endef + +%frame_exclude% += import-names +define import-names +$(foreach i,1 2 3 4 5 6 7,$(if $(lastword $(value $i)),\ +$(call import-set-value,$(lastword $(value $i)),$(value $(firstword $(value $i)))))) +endef + +%frame_exclude% += import-body +define import-body +$(call frame-enter,$(call exported-names,$2,$3,$4,$5,$6,$7,$8)) + +$(call include,$1) + +$(call import-names,$2,$3,$4,$5,$6,$7,$8) + +$(call frame-leave) +endef + + +# Simple case where there are no names imported. Also note that we use +# include-once here since there is no reason to do it more than once. +# We key it onto out_root to make sure we don't process the same makefile +# more than once since that's what export stubs do. +# +%frame_exclude% += import-body-simple +define import-body-simple +$(call frame-enter) + +$(call include-once,$1,$(out_root)) + +$(call frame-leave) +endef + + +# +# +%frame_exclude% += import +define import +$(eval $(if $(strip $2),\ +$(call import-body,$1,$2,$3,$4,$5,$6,$7,$8),\ +$(call import-body-simple,$1))) +endef + + +# +# export +# +%frame_exclude% += export-names +define export-names +$(foreach i,1 2 3 4 5 6 7,$(if $(value $i),\ +$(call import-set-value,$(firstword $(value $i)),$(wordlist 2,$(words $(value $i)),$(value $i))))) +endef + + +%frame_exclude% += export +define export +$(call export-names,$1,$2,$3,$4,$5,$6,$7) +endef diff --git a/build/install.make b/build/install.make new file mode 100644 index 0000000..213ad28 --- /dev/null +++ b/build/install.make @@ -0,0 +1,7 @@ +# file : build/install/install.make +# author : Boris Kolpackov <boris@codesynthesis.com> +# copyright : Copyright (c) 2004-2010 Code Synthesis Tools CC +# license : GNU GPL v2; see accompanying LICENSE file + +$(call include,$(bld_root)/install/configuration.make) +$(call include-once,$(bld_root)/install/install-functions.make,$(out_base)) diff --git a/build/install/configuration.make b/build/install/configuration.make new file mode 100644 index 0000000..66c9dd3 --- /dev/null +++ b/build/install/configuration.make @@ -0,0 +1,46 @@ +# file : build/install/configuration.make +# author : Boris Kolpackov <boris@codesynthesis.com> +# copyright : Copyright (c) 2004-2010 Code Synthesis Tools CC +# license : GNU GPL v2; see accompanying LICENSE file + +install_prefix := /usr/local +install_data_prefix := $(install_prefix) +install_exec_prefix := $(install_prefix) + +install_bin_dir := $(install_exec_prefix)/bin +install_sbin_dir := $(install_exec_prefix)/sbin +install_lib_dir := $(install_exec_prefix)/lib + +install_data_dir := $(install_data_prefix)/share +install_inc_dir := $(install_data_prefix)/include + +install_doc_dir := $(install_data_dir)/doc +install_man_dir := $(install_data_dir)/man +install_info_dir := $(install_data_dir)/info + +$(out_root)/%: install_bin_dir := $(install_bin_dir) +$(out_root)/%: install_sbin_dir := $(install_sbin_dir) +$(out_root)/%: install_lib_dir := $(install_lib_dir) + +$(out_root)/%: install_inc_dir := $(install_inc_dir) +$(out_root)/%: install_data_dir := $(install_data_dir) + +$(out_root)/%: install_doc_dir := $(install_doc_dir) +$(out_root)/%: install_man_dir := $(install_man_dir) +$(out_root)/%: install_info_dir := $(install_info_dir) + +install_cmd := $(bld_root)/install/install + +install_dir := $(install_cmd) -d -m 755 +install_data := $(install_cmd) -p -m 644 +install_exec := $(install_cmd) -p -m 755 + +$(out_root)/%: install_dir := $(install_dir) +$(out_root)/%: install_data := $(install_data) +$(out_root)/%: install_exec := $(install_exec) + + +#@@ Installation process is very os-dependant. For example +# on BSD there is libexec but there is no such thing on +# GNU/Linux. +# diff --git a/build/install/install b/build/install/install new file mode 100755 index 0000000..20193b6 --- /dev/null +++ b/build/install/install @@ -0,0 +1,22 @@ +#! /usr/bin/env bash + +# file : build/install/install +# author : Boris Kolpackov <boris@codesynthesis.com> +# copyright : Copyright (c) 2004-2010 Code Synthesis Tools CC +# license : GNU GPL v2; see accompanying LICENSE file + +# Run native install command if available and install-sh otherwise. +# Also strip the -p argument (should be first) if calling install-sh +# which doesn't support it. +# + +type install >/dev/null 2>&1 + +if [ $? -eq 0 ]; then + exec install $* +else + if [ "$1" = "-p" ]; then + shift + fi + exec `dirname $0`/install-sh $* +fi diff --git a/build/install/install-functions.make b/build/install/install-functions.make new file mode 100644 index 0000000..4434cbe --- /dev/null +++ b/build/install/install-functions.make @@ -0,0 +1,38 @@ +# file : build/install/install-functions.make +# author : Boris Kolpackov <boris@codesynthesis.com> +# copyright : Copyright (c) 2004-2010 Code Synthesis Tools CC +# license : GNU GPL v2; see accompanying LICENSE file + +#@@ could just call it functions.make +# + +$(out_base)/%: install-exec = \ +$(call message,,$(install_dir) $(dir $2))$(literal_newline)\ +$(literal_tab)$(call message,install $2,$(install_exec) $1 $2) + + +$(out_base)/%: install-lib = \ +$(call message,install $2,$(install_dir) $(dir $2))$(literal_newline)\ +$(literal_tab)$(call message,,$(value $(if $(patsubst %.so,,$(shell\ + sed -e '1q' <$1)),install_data,install_exec)) $(shell sed -e '1q' <$1) $2) + + +$(out_base)/%: install-data = \ +$(call message,install $2,$(install_dir) $(dir $2))$(literal_newline)\ +$(literal_tab)$(call message,,$(install_data) $1 $2) + + +$(out_base)/%: install-dir = \ +$(call message,install $2/,find -L $1 $3 -type f -print \ +| xargs -n 1 $(bld_root)/run-if-arg dirname \ +| sort -u \ +| sed -e 's%$1\(.*\)%$2/\1%' \ +| xargs -n 1 $(bld_root)/run-if-arg "$(install_dir)")$(literal_newline)\ +$(literal_tab)$(call message,,\ +find -L $1 $3 -type f ! -perm -100 -print \ +| sed -e 's%$1\(.*\)%$1/\1 $2/\1%' \ +| xargs -n 2 $(bld_root)/run-if-arg "$(install_data)")$(literal_newline)\ +$(literal_tab)$(call message,,\ +find -L $1 $3 -type f -perm -100 -print \ +| sed -e 's%$1\(.*\)%$1/\1 $2/\1%' \ +| xargs -n 2 $(bld_root)/run-if-arg "$(install_exec)") diff --git a/build/install/install-sh b/build/install/install-sh new file mode 100755 index 0000000..a5897de --- /dev/null +++ b/build/install/install-sh @@ -0,0 +1,519 @@ +#!/bin/sh +# install - install a program, script, or datafile + +scriptversion=2006-12-25.00 + +# This originates from X11R5 (mit/util/scripts/install.sh), which was +# later released in X11R6 (xc/config/util/install.sh) with the +# following copyright and license. +# +# Copyright (C) 1994 X Consortium +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the "Software"), to +# deal in the Software without restriction, including without limitation the +# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or +# sell copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in +# all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN +# AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNEC- +# TION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +# +# Except as contained in this notice, the name of the X Consortium shall not +# be used in advertising or otherwise to promote the sale, use or other deal- +# ings in this Software without prior written authorization from the X Consor- +# tium. +# +# +# FSF changes to this file are in the public domain. +# +# 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. + +nl=' +' +IFS=" "" $nl" + +# set DOITPROG to echo to test this script + +# Don't use :- since 4.3BSD and earlier shells don't like it. +doit=${DOITPROG-} +if test -z "$doit"; then + doit_exec=exec +else + doit_exec=$doit +fi + +# Put in absolute file names if you don't have them in your path; +# or use environment vars. + +chgrpprog=${CHGRPPROG-chgrp} +chmodprog=${CHMODPROG-chmod} +chownprog=${CHOWNPROG-chown} +cmpprog=${CMPPROG-cmp} +cpprog=${CPPROG-cp} +mkdirprog=${MKDIRPROG-mkdir} +mvprog=${MVPROG-mv} +rmprog=${RMPROG-rm} +stripprog=${STRIPPROG-strip} + +posix_glob='?' +initialize_posix_glob=' + test "$posix_glob" != "?" || { + if (set -f) 2>/dev/null; then + posix_glob= + else + posix_glob=: + fi + } +' + +posix_mkdir= + +# Desired mode of installed file. +mode=0755 + +chgrpcmd= +chmodcmd=$chmodprog +chowncmd= +mvcmd=$mvprog +rmcmd="$rmprog -f" +stripcmd= + +src= +dst= +dir_arg= +dst_arg= + +copy_on_change=false +no_target_directory= + +usage="\ +Usage: $0 [OPTION]... [-T] SRCFILE DSTFILE + or: $0 [OPTION]... SRCFILES... DIRECTORY + or: $0 [OPTION]... -t DIRECTORY SRCFILES... + or: $0 [OPTION]... -d DIRECTORIES... + +In the 1st form, copy SRCFILE to DSTFILE. +In the 2nd and 3rd, copy all SRCFILES to DIRECTORY. +In the 4th, create DIRECTORIES. + +Options: + --help display this help and exit. + --version display version info and exit. + + -c (ignored) + -C install only if different (preserve the last data modification time) + -d create directories instead of installing files. + -g GROUP $chgrpprog installed files to GROUP. + -m MODE $chmodprog installed files to MODE. + -o USER $chownprog installed files to USER. + -s $stripprog installed files. + -t DIRECTORY install into DIRECTORY. + -T report an error if DSTFILE is a directory. + +Environment variables override the default commands: + CHGRPPROG CHMODPROG CHOWNPROG CMPPROG CPPROG MKDIRPROG MVPROG + RMPROG STRIPPROG +" + +while test $# -ne 0; do + case $1 in + -c) ;; + + -C) copy_on_change=true;; + + -d) dir_arg=true;; + + -g) chgrpcmd="$chgrpprog $2" + shift;; + + --help) echo "$usage"; exit $?;; + + -m) mode=$2 + case $mode in + *' '* | *' '* | *' +'* | *'*'* | *'?'* | *'['*) + echo "$0: invalid mode: $mode" >&2 + exit 1;; + esac + shift;; + + -o) chowncmd="$chownprog $2" + shift;; + + -s) stripcmd=$stripprog;; + + -t) dst_arg=$2 + shift;; + + -T) no_target_directory=true;; + + --version) echo "$0 $scriptversion"; exit $?;; + + --) shift + break;; + + -*) echo "$0: invalid option: $1" >&2 + exit 1;; + + *) break;; + esac + shift +done + +if test $# -ne 0 && test -z "$dir_arg$dst_arg"; then + # When -d is used, all remaining arguments are directories to create. + # When -t is used, the destination is already specified. + # Otherwise, the last argument is the destination. Remove it from $@. + for arg + do + if test -n "$dst_arg"; then + # $@ is not empty: it contains at least $arg. + set fnord "$@" "$dst_arg" + shift # fnord + fi + shift # arg + dst_arg=$arg + done +fi + +if test $# -eq 0; then + if test -z "$dir_arg"; then + echo "$0: no input file specified." >&2 + exit 1 + fi + # It's OK to call `install-sh -d' without argument. + # This can happen when creating conditional directories. + exit 0 +fi + +if test -z "$dir_arg"; then + trap '(exit $?); exit' 1 2 13 15 + + # Set umask so as not to create temps with too-generous modes. + # However, 'strip' requires both read and write access to temps. + case $mode in + # Optimize common cases. + *644) cp_umask=133;; + *755) cp_umask=22;; + + *[0-7]) + if test -z "$stripcmd"; then + u_plus_rw= + else + u_plus_rw='% 200' + fi + cp_umask=`expr '(' 777 - $mode % 1000 ')' $u_plus_rw`;; + *) + if test -z "$stripcmd"; then + u_plus_rw= + else + u_plus_rw=,u+rw + fi + cp_umask=$mode$u_plus_rw;; + esac +fi + +for src +do + # Protect names starting with `-'. + case $src in + -*) src=./$src;; + esac + + if test -n "$dir_arg"; then + dst=$src + dstdir=$dst + test -d "$dstdir" + dstdir_status=$? + else + + # Waiting for this to be detected by the "$cpprog $src $dsttmp" command + # might cause directories to be created, which would be especially bad + # if $src (and thus $dsttmp) contains '*'. + if test ! -f "$src" && test ! -d "$src"; then + echo "$0: $src does not exist." >&2 + exit 1 + fi + + if test -z "$dst_arg"; then + echo "$0: no destination specified." >&2 + exit 1 + fi + + dst=$dst_arg + # Protect names starting with `-'. + case $dst in + -*) dst=./$dst;; + esac + + # If destination is a directory, append the input filename; won't work + # if double slashes aren't ignored. + if test -d "$dst"; then + if test -n "$no_target_directory"; then + echo "$0: $dst_arg: Is a directory" >&2 + exit 1 + fi + dstdir=$dst + dst=$dstdir/`basename "$src"` + dstdir_status=0 + else + # Prefer dirname, but fall back on a substitute if dirname fails. + dstdir=` + (dirname "$dst") 2>/dev/null || + expr X"$dst" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ + X"$dst" : 'X\(//\)[^/]' \| \ + X"$dst" : 'X\(//\)$' \| \ + X"$dst" : 'X\(/\)' \| . 2>/dev/null || + echo X"$dst" | + sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ + s//\1/ + q + } + /^X\(\/\/\)[^/].*/{ + s//\1/ + q + } + /^X\(\/\/\)$/{ + s//\1/ + q + } + /^X\(\/\).*/{ + s//\1/ + q + } + s/.*/./; q' + ` + + test -d "$dstdir" + dstdir_status=$? + fi + fi + + obsolete_mkdir_used=false + + if test $dstdir_status != 0; then + case $posix_mkdir in + '') + # Create intermediate dirs using mode 755 as modified by the umask. + # This is like FreeBSD 'install' as of 1997-10-28. + umask=`umask` + case $stripcmd.$umask in + # Optimize common cases. + *[2367][2367]) mkdir_umask=$umask;; + .*0[02][02] | .[02][02] | .[02]) mkdir_umask=22;; + + *[0-7]) + mkdir_umask=`expr $umask + 22 \ + - $umask % 100 % 40 + $umask % 20 \ + - $umask % 10 % 4 + $umask % 2 + `;; + *) mkdir_umask=$umask,go-w;; + esac + + # With -d, create the new directory with the user-specified mode. + # Otherwise, rely on $mkdir_umask. + if test -n "$dir_arg"; then + mkdir_mode=-m$mode + else + mkdir_mode= + fi + + posix_mkdir=false + case $umask in + *[123567][0-7][0-7]) + # POSIX mkdir -p sets u+wx bits regardless of umask, which + # is incompatible with FreeBSD 'install' when (umask & 300) != 0. + ;; + *) + tmpdir=${TMPDIR-/tmp}/ins$RANDOM-$$ + trap 'ret=$?; rmdir "$tmpdir/d" "$tmpdir" 2>/dev/null; exit $ret' 0 + + if (umask $mkdir_umask && + exec $mkdirprog $mkdir_mode -p -- "$tmpdir/d") >/dev/null 2>&1 + then + if test -z "$dir_arg" || { + # Check for POSIX incompatibilities with -m. + # HP-UX 11.23 and IRIX 6.5 mkdir -m -p sets group- or + # other-writeable bit of parent directory when it shouldn't. + # FreeBSD 6.1 mkdir -m -p sets mode of existing directory. + ls_ld_tmpdir=`ls -ld "$tmpdir"` + case $ls_ld_tmpdir in + d????-?r-*) different_mode=700;; + d????-?--*) different_mode=755;; + *) false;; + esac && + $mkdirprog -m$different_mode -p -- "$tmpdir" && { + ls_ld_tmpdir_1=`ls -ld "$tmpdir"` + test "$ls_ld_tmpdir" = "$ls_ld_tmpdir_1" + } + } + then posix_mkdir=: + fi + rmdir "$tmpdir/d" "$tmpdir" + else + # Remove any dirs left behind by ancient mkdir implementations. + rmdir ./$mkdir_mode ./-p ./-- 2>/dev/null + fi + trap '' 0;; + esac;; + esac + + if + $posix_mkdir && ( + umask $mkdir_umask && + $doit_exec $mkdirprog $mkdir_mode -p -- "$dstdir" + ) + then : + else + + # The umask is ridiculous, or mkdir does not conform to POSIX, + # or it failed possibly due to a race condition. Create the + # directory the slow way, step by step, checking for races as we go. + + case $dstdir in + /*) prefix='/';; + -*) prefix='./';; + *) prefix='';; + esac + + eval "$initialize_posix_glob" + + oIFS=$IFS + IFS=/ + $posix_glob set -f + set fnord $dstdir + shift + $posix_glob set +f + IFS=$oIFS + + prefixes= + + for d + do + test -z "$d" && continue + + prefix=$prefix$d + if test -d "$prefix"; then + prefixes= + else + if $posix_mkdir; then + (umask=$mkdir_umask && + $doit_exec $mkdirprog $mkdir_mode -p -- "$dstdir") && break + # Don't fail if two instances are running concurrently. + test -d "$prefix" || exit 1 + else + case $prefix in + *\'*) qprefix=`echo "$prefix" | sed "s/'/'\\\\\\\\''/g"`;; + *) qprefix=$prefix;; + esac + prefixes="$prefixes '$qprefix'" + fi + fi + prefix=$prefix/ + done + + if test -n "$prefixes"; then + # Don't fail if two instances are running concurrently. + (umask $mkdir_umask && + eval "\$doit_exec \$mkdirprog $prefixes") || + test -d "$dstdir" || exit 1 + obsolete_mkdir_used=true + fi + fi + fi + + if test -n "$dir_arg"; then + { test -z "$chowncmd" || $doit $chowncmd "$dst"; } && + { test -z "$chgrpcmd" || $doit $chgrpcmd "$dst"; } && + { test "$obsolete_mkdir_used$chowncmd$chgrpcmd" = false || + test -z "$chmodcmd" || $doit $chmodcmd $mode "$dst"; } || exit 1 + else + + # Make a couple of temp file names in the proper directory. + dsttmp=$dstdir/_inst.$$_ + rmtmp=$dstdir/_rm.$$_ + + # Trap to clean up those temp files at exit. + trap 'ret=$?; rm -f "$dsttmp" "$rmtmp" && exit $ret' 0 + + # Copy the file name to the temp name. + (umask $cp_umask && $doit_exec $cpprog "$src" "$dsttmp") && + + # 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 $cpprog $src $dsttmp" command. + # + { test -z "$chowncmd" || $doit $chowncmd "$dsttmp"; } && + { test -z "$chgrpcmd" || $doit $chgrpcmd "$dsttmp"; } && + { test -z "$stripcmd" || $doit $stripcmd "$dsttmp"; } && + { test -z "$chmodcmd" || $doit $chmodcmd $mode "$dsttmp"; } && + + # If -C, don't bother to copy if it wouldn't change the file. + if $copy_on_change && + old=`LC_ALL=C ls -dlL "$dst" 2>/dev/null` && + new=`LC_ALL=C ls -dlL "$dsttmp" 2>/dev/null` && + + eval "$initialize_posix_glob" && + $posix_glob set -f && + set X $old && old=:$2:$4:$5:$6 && + set X $new && new=:$2:$4:$5:$6 && + $posix_glob set +f && + + test "$old" = "$new" && + $cmpprog "$dst" "$dsttmp" >/dev/null 2>&1 + then + rm -f "$dsttmp" + else + # Rename the file to the real destination. + $doit $mvcmd -f "$dsttmp" "$dst" 2>/dev/null || + + # The rename failed, perhaps because mv can't rename something else + # to itself, or perhaps because mv is so ancient that it does not + # support -f. + { + # Now remove or move aside any old file at destination location. + # We try this two ways since rm can't unlink itself on some + # systems and the destination file might be busy for other + # reasons. In this case, the final cleanup might fail but the new + # file should still install successfully. + { + test ! -f "$dst" || + $doit $rmcmd -f "$dst" 2>/dev/null || + { $doit $mvcmd -f "$dst" "$rmtmp" 2>/dev/null && + { $doit $rmcmd -f "$rmtmp" 2>/dev/null; :; } + } || + { echo "$0: cannot unlink or rename $dst" >&2 + (exit 1); exit 1 + } + } && + + # Now rename the file to the real destination. + $doit $mvcmd "$dsttmp" "$dst" + } + fi || exit 1 + + trap '' 0 + fi +done + +# Local variables: +# eval: (add-hook 'write-file-hooks 'time-stamp) +# time-stamp-start: "scriptversion=" +# time-stamp-format: "%:y-%02m-%02d.%02H" +# time-stamp-end: "$" +# End: diff --git a/build/ld/configuration-lib-rules.make b/build/ld/configuration-lib-rules.make new file mode 100644 index 0000000..686d975 --- /dev/null +++ b/build/ld/configuration-lib-rules.make @@ -0,0 +1,16 @@ +# file : build/ld/configuration-lib-rules.make +# author : Boris Kolpackov <boris@codesynthesis.com> +# copyright : Copyright (c) 2004-2010 Code Synthesis Tools CC +# license : GNU GPL v2; see accompanying LICENSE file + +$(dcf_root)/ld/configuration-lib-dynamic.make: | $(dcf_root)/ld/. + $(call message,,$(bld_root)/ld/configure-lib $@) + + +ifndef %foreign% + +disfigure:: + $(call message,rm $(dcf_root)/ld/configuration-lib-dynamic.make,\ +rm -f $(dcf_root)/ld/configuration-lib-dynamic.make) + +endif diff --git a/build/ld/configuration-lib-static.make b/build/ld/configuration-lib-static.make new file mode 100644 index 0000000..5d26e8a --- /dev/null +++ b/build/ld/configuration-lib-static.make @@ -0,0 +1,10 @@ +# file : build/ld/configuration-lib-static.make +# author : Boris Kolpackov <boris@codesynthesis.com> +# copyright : Copyright (c) 2004-2010 Code Synthesis Tools CC +# license : GNU GPL v2; see accompanying LICENSE file + +#@@ Need to use these variables where I hardcoded those values. +# +ld_lib_prefix := lib +ld_lib_archive_suffix := .a +ld_lib_shared_suffix := .so diff --git a/build/ld/configuration-lib.make b/build/ld/configuration-lib.make new file mode 100644 index 0000000..6b910c5 --- /dev/null +++ b/build/ld/configuration-lib.make @@ -0,0 +1,42 @@ +# file : build/ld/configuration-lib.make +# author : Boris Kolpackov <boris@codesynthesis.com> +# copyright : Copyright (c) 2004-2010 Code Synthesis Tools CC +# license : GNU GPL v2; see accompanying LICENSE file + +$(call include-once,$(bld_root)/ld/configuration-lib-rules.make,$(dcf_root)) + +# Static configuration. +# +$(call include,$(bld_root)/ld/configuration-lib-static.make) + +ifneq ($(bld_root),$(scf_root)) +$(call -include,$(scf_root)/ld/configuration-lib-static.make) +endif + +# Dynamic configuration. +# +ld_lib_type := + +$(call -include,$(dcf_root)/ld/configuration-lib-dynamic.make) + +ifdef ld_lib_type + +ifeq ($(ld_lib_type),archive) + +ld_lib_suffix := $(ld_lib_archive_suffix) + +else + +ld_lib_suffix := $(ld_lib_shared_suffix) + +endif + +$(out_root)/%: ld_lib_type := $(ld_lib_type) +$(out_root)/%: ld_lib_prefix := $(ld_lib_prefix) +$(out_root)/%: ld_lib_suffix := $(ld_lib_suffix) + +else + +.NOTPARALLEL: + +endif diff --git a/build/ld/configure-lib b/build/ld/configure-lib new file mode 100755 index 0000000..84a2c2b --- /dev/null +++ b/build/ld/configure-lib @@ -0,0 +1,51 @@ +#! /usr/bin/env bash + +# file : build/ld/configure-lib +# author : Boris Kolpackov <boris@codesynthesis.com> +# copyright : Copyright (c) 2004-2010 Code Synthesis Tools CC +# license : GNU GPL v2; see accompanying LICENSE file + +# $1 out file +# +# bld_root - build root +# project_name - project name +# + +source $bld_root/dialog.bash + +$echo +$echo +$echo "configuring '$project_name'" +$echo +$echo + +$echo +$echo "Please select the default library type:" +$echo +$echo "(1) archive" +$echo "(2) shared object" +$echo + +type=`read_option "archive shared" "shared"` + +if [ "$type" == "archive" ]; then + + $echo + $echo "Please enter the archiver (ar) binary you would like to use." + $echo + + ar=`read_path --command ar` + + $echo + $echo "Please enter the indexer (ranlib) binary you would like to use." + $echo + + ranlib=`read_path --command ranlib` +fi + +echo "ld_lib_type := $type" > $1 + +if [ "$type" == "archive" ]; then + echo "ld_lib_ar := $ar" >> $1 + echo "ld_lib_ranlib := $ranlib" >> $1 +fi diff --git a/build/literals.make b/build/literals.make new file mode 100644 index 0000000..0528793 --- /dev/null +++ b/build/literals.make @@ -0,0 +1,14 @@ +# file : build/literals.make +# author : Boris Kolpackov <boris@codesynthesis.com> +# copyright : Copyright (c) 2004-2010 Code Synthesis Tools CC +# license : GNU GPL v2; see accompanying LICENSE file + +literal_empty := + +define literal_newline + + +endef + +literal_tab := $(literal_empty) $(literal_empty) +literal_percent := % diff --git a/build/m4/m4.make b/build/m4/m4.make new file mode 100644 index 0000000..96cd963 --- /dev/null +++ b/build/m4/m4.make @@ -0,0 +1,51 @@ +# file : build/m4/m4.make +# author : Boris Kolpackov <boris@codesynthesis.com> +# copyright : Copyright (c) 2005-2010 Code Synthesis Tools CC +# license : GNU GPL v2; see accompanying LICENSE file + +$(out_base)/%: m4 := m4 +$(out_base)/%: m4_options += + +ifeq ($(out_base),$(src_base)) +$(out_base)/%: $(src_base)/%.m4 +else +$(out_base)/%: $(src_base)/%.m4 | $$(dir $$@). +endif + $(call message,m4 $<,$(m4) $(m4_options) $< >$@) + +ifneq ($(out_base),$(src_base)) + +$(out_base)/%: $(out_base)/%.m4 | $$(dir $$@). + $(call message,m4 $<,$(m4) $(m4_options) $< >$@) + +endif + + +# @@ +# This is where things start breaking. Following standard logic I should +# make a $(out_base)/%.clean rule, i.e., "will clean anything" rule. If +# this rule happened to be before some other, more specialized rule, and +# that rule happened to rm some additional stuff (like %.o tries to rm +# .d file, which is also not quite correct...). In other word there +# doesn't seem to be a way to properly match "build" and "clean" rules. +# One idea is to make the "clean" rule depend on what "build" rule +# depends (%.m4 in our case) hoping that this way the rule won't match. +# +# There are two problems with this approach: +# +# 1. It is if not iff. However, since the rules come in pairs and make +# pick the first implicit rule that matches, it is certain that if +# make picked this "clean" rule it also picked corresponding "build" +# rule. +# +# 2. The prerequisite (%.m4) can be an intermidiate file which itself +# may not exist. We don't want make to build it just to clean it +# or, even worse, to leave it laying around. I guess the only way +# to work around this is to provide special do-nothing rules during +# cleanup. +# +# +.PHONY: $(out_base)/%.m4.clean + +$(out_base)/%.m4.clean: + $(call message,rm $(@:.m4.clean=),rm -f $(@:.m4.clean=)) diff --git a/build/message.make b/build/message.make new file mode 100644 index 0000000..ff499e6 --- /dev/null +++ b/build/message.make @@ -0,0 +1,36 @@ +# file : build/message.make +# author : Boris Kolpackov <boris@codesynthesis.com> +# copyright : Copyright (c) 2004-2010 Code Synthesis Tools CC +# license : GNU GPL v2; see accompanying LICENSE file + + +# @@ I should not use names like message especially if it is +# just for a convinience of a subsystem. +# +# @@ maybe I can use -message (use - in front for system +# utilities). +# + +%frame_exclude% += build-message-expand +define build-message-expand +$(eval _1 = $1)$(call _1,$2,$3,$4,$5,$6,$7,$8,$9) +endef + + +%frame_exclude% += message + +ifdef verbose + +define message +$(call build-message-expand,$2,$3,$4,$5,$6,$7,$8,$9) +endef + +else + +define message +$(if $1,@echo $(call build-message-expand,$1,$3,$4,$5,$6,$7,$8,$9) && \ + $(call build-message-expand,$2,$3,$4,$5,$6,$7,$8,$9),\ + @$(call build-message-expand,$2,$3,$4,$5,$6,$7,$8,$9)) +endef + +endif diff --git a/build/run-if-arg b/build/run-if-arg new file mode 100755 index 0000000..819a3cb --- /dev/null +++ b/build/run-if-arg @@ -0,0 +1,18 @@ +#! /usr/bin/env bash + +# file : build/run-if-arg +# author : Boris Kolpackov <boris@codesynthesis.com> +# copyright : Copyright (c) 2004-2010 Code Synthesis Tools CC +# license : GNU GPL v2; see accompanying LICENSE file + +# Run command if there are any non-empty arguments. +# +# $1 command to execute +# $2 argument to test + +cmd=$1 +shift + +if [ "$*" ]; then + exec $cmd $* +fi diff --git a/build/system.make b/build/system.make new file mode 100644 index 0000000..7de97db --- /dev/null +++ b/build/system.make @@ -0,0 +1,14 @@ +# file : build/system.make +# author : Boris Kolpackov <boris@codesynthesis.com> +# copyright : Copyright (c) 2006-2010 Code Synthesis Tools CC +# license : GNU GPL v2; see accompanying LICENSE file + +$(call include-once,$(bld_root)/system/configuration-rules.make,$(dcf_root)) + +$(call -include,$(dcf_root)/system/configuration-dynamic.make) + +ifndef system_configuration + +.NOTPARALLEL: + +endif diff --git a/build/system/config.guess b/build/system/config.guess new file mode 100755 index 0000000..e792aac --- /dev/null +++ b/build/system/config.guess @@ -0,0 +1,1494 @@ +#! /bin/sh +# Attempt to guess a canonical system name. +# Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, +# 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009 +# Free Software Foundation, Inc. + +timestamp='2009-09-18' + +# This file is free software; you can redistribute it and/or modify it +# under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA +# 02110-1301, USA. +# +# As a special exception to the GNU General Public License, if you +# distribute this file as part of a program that contains a +# configuration script generated by Autoconf, you may include it under +# the same distribution terms that you use for the rest of that program. + + +# Originally written by Per Bothner. Please send patches (context +# diff format) to <config-patches@gnu.org> and include a ChangeLog +# entry. +# +# This script attempts to guess a canonical system name similar to +# config.sub. If it succeeds, it prints the system name on stdout, and +# exits with 0. Otherwise, it exits with 1. +# +# You can get the latest version of this script from: +# http://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.guess;hb=HEAD + +me=`echo "$0" | sed -e 's,.*/,,'` + +usage="\ +Usage: $0 [OPTION] + +Output the configuration name of the system \`$me' is run on. + +Operation modes: + -h, --help print this help, then exit + -t, --time-stamp print date of last modification, then exit + -v, --version print version number, then exit + +Report bugs and patches to <config-patches@gnu.org>." + +version="\ +GNU config.guess ($timestamp) + +Originally written by Per Bothner. +Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, +2002, 2003, 2004, 2005, 2006, 2007, 2008 Free Software Foundation, Inc. + +This is free software; see the source for copying conditions. There is NO +warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE." + +help=" +Try \`$me --help' for more information." + +# Parse command line +while test $# -gt 0 ; do + case $1 in + --time-stamp | --time* | -t ) + echo "$timestamp" ; exit ;; + --version | -v ) + echo "$version" ; exit ;; + --help | --h* | -h ) + echo "$usage"; exit ;; + -- ) # Stop option processing + shift; break ;; + - ) # Use stdin as input. + break ;; + -* ) + echo "$me: invalid option $1$help" >&2 + exit 1 ;; + * ) + break ;; + esac +done + +if test $# != 0; then + echo "$me: too many arguments$help" >&2 + exit 1 +fi + +trap 'exit 1' 1 2 15 + +# CC_FOR_BUILD -- compiler used by this script. Note that the use of a +# compiler to aid in system detection is discouraged as it requires +# temporary files to be created and, as you can see below, it is a +# headache to deal with in a portable fashion. + +# Historically, `CC_FOR_BUILD' used to be named `HOST_CC'. We still +# use `HOST_CC' if defined, but it is deprecated. + +# Portable tmp directory creation inspired by the Autoconf team. + +set_cc_for_build=' +trap "exitcode=\$?; (rm -f \$tmpfiles 2>/dev/null; rmdir \$tmp 2>/dev/null) && exit \$exitcode" 0 ; +trap "rm -f \$tmpfiles 2>/dev/null; rmdir \$tmp 2>/dev/null; exit 1" 1 2 13 15 ; +: ${TMPDIR=/tmp} ; + { tmp=`(umask 077 && mktemp -d "$TMPDIR/cgXXXXXX") 2>/dev/null` && test -n "$tmp" && test -d "$tmp" ; } || + { test -n "$RANDOM" && tmp=$TMPDIR/cg$$-$RANDOM && (umask 077 && mkdir $tmp) ; } || + { tmp=$TMPDIR/cg-$$ && (umask 077 && mkdir $tmp) && echo "Warning: creating insecure temp directory" >&2 ; } || + { echo "$me: cannot create a temporary directory in $TMPDIR" >&2 ; exit 1 ; } ; +dummy=$tmp/dummy ; +tmpfiles="$dummy.c $dummy.o $dummy.rel $dummy" ; +case $CC_FOR_BUILD,$HOST_CC,$CC in + ,,) echo "int x;" > $dummy.c ; + for c in cc gcc c89 c99 ; do + if ($c -c -o $dummy.o $dummy.c) >/dev/null 2>&1 ; then + CC_FOR_BUILD="$c"; break ; + fi ; + done ; + if test x"$CC_FOR_BUILD" = x ; then + CC_FOR_BUILD=no_compiler_found ; + fi + ;; + ,,*) CC_FOR_BUILD=$CC ;; + ,*,*) CC_FOR_BUILD=$HOST_CC ;; +esac ; set_cc_for_build= ;' + +# This is needed to find uname on a Pyramid OSx when run in the BSD universe. +# (ghazi@noc.rutgers.edu 1994-08-24) +if (test -f /.attbin/uname) >/dev/null 2>&1 ; then + PATH=$PATH:/.attbin ; export PATH +fi + +UNAME_MACHINE=`(uname -m) 2>/dev/null` || UNAME_MACHINE=unknown +UNAME_RELEASE=`(uname -r) 2>/dev/null` || UNAME_RELEASE=unknown +UNAME_SYSTEM=`(uname -s) 2>/dev/null` || UNAME_SYSTEM=unknown +UNAME_VERSION=`(uname -v) 2>/dev/null` || UNAME_VERSION=unknown + +# Note: order is significant - the case branches are not exclusive. + +case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in + *:NetBSD:*:*) + # NetBSD (nbsd) targets should (where applicable) match one or + # more of the tupples: *-*-netbsdelf*, *-*-netbsdaout*, + # *-*-netbsdecoff* and *-*-netbsd*. For targets that recently + # switched to ELF, *-*-netbsd* would select the old + # object file format. This provides both forward + # compatibility and a consistent mechanism for selecting the + # object file format. + # + # Note: NetBSD doesn't particularly care about the vendor + # portion of the name. We always set it to "unknown". + sysctl="sysctl -n hw.machine_arch" + UNAME_MACHINE_ARCH=`(/sbin/$sysctl 2>/dev/null || \ + /usr/sbin/$sysctl 2>/dev/null || echo unknown)` + case "${UNAME_MACHINE_ARCH}" in + armeb) machine=armeb-unknown ;; + arm*) machine=arm-unknown ;; + sh3el) machine=shl-unknown ;; + sh3eb) machine=sh-unknown ;; + sh5el) machine=sh5le-unknown ;; + *) machine=${UNAME_MACHINE_ARCH}-unknown ;; + esac + # The Operating System including object format, if it has switched + # to ELF recently, or will in the future. + case "${UNAME_MACHINE_ARCH}" in + arm*|i386|m68k|ns32k|sh3*|sparc|vax) + eval $set_cc_for_build + if echo __ELF__ | $CC_FOR_BUILD -E - 2>/dev/null \ + | grep -q __ELF__ + then + # Once all utilities can be ECOFF (netbsdecoff) or a.out (netbsdaout). + # Return netbsd for either. FIX? + os=netbsd + else + os=netbsdelf + fi + ;; + *) + os=netbsd + ;; + esac + # The OS release + # Debian GNU/NetBSD machines have a different userland, and + # thus, need a distinct triplet. However, they do not need + # kernel version information, so it can be replaced with a + # suitable tag, in the style of linux-gnu. + case "${UNAME_VERSION}" in + Debian*) + release='-gnu' + ;; + *) + release=`echo ${UNAME_RELEASE}|sed -e 's/[-_].*/\./'` + ;; + esac + # Since CPU_TYPE-MANUFACTURER-KERNEL-OPERATING_SYSTEM: + # contains redundant information, the shorter form: + # CPU_TYPE-MANUFACTURER-OPERATING_SYSTEM is used. + echo "${machine}-${os}${release}" + exit ;; + *:OpenBSD:*:*) + UNAME_MACHINE_ARCH=`arch | sed 's/OpenBSD.//'` + echo ${UNAME_MACHINE_ARCH}-unknown-openbsd${UNAME_RELEASE} + exit ;; + *:ekkoBSD:*:*) + echo ${UNAME_MACHINE}-unknown-ekkobsd${UNAME_RELEASE} + exit ;; + *:SolidBSD:*:*) + echo ${UNAME_MACHINE}-unknown-solidbsd${UNAME_RELEASE} + exit ;; + macppc:MirBSD:*:*) + echo powerpc-unknown-mirbsd${UNAME_RELEASE} + exit ;; + *:MirBSD:*:*) + echo ${UNAME_MACHINE}-unknown-mirbsd${UNAME_RELEASE} + exit ;; + alpha:OSF1:*:*) + case $UNAME_RELEASE in + *4.0) + UNAME_RELEASE=`/usr/sbin/sizer -v | awk '{print $3}'` + ;; + *5.*) + UNAME_RELEASE=`/usr/sbin/sizer -v | awk '{print $4}'` + ;; + esac + # According to Compaq, /usr/sbin/psrinfo has been available on + # OSF/1 and Tru64 systems produced since 1995. I hope that + # covers most systems running today. This code pipes the CPU + # types through head -n 1, so we only detect the type of CPU 0. + ALPHA_CPU_TYPE=`/usr/sbin/psrinfo -v | sed -n -e 's/^ The alpha \(.*\) processor.*$/\1/p' | head -n 1` + case "$ALPHA_CPU_TYPE" in + "EV4 (21064)") + UNAME_MACHINE="alpha" ;; + "EV4.5 (21064)") + UNAME_MACHINE="alpha" ;; + "LCA4 (21066/21068)") + UNAME_MACHINE="alpha" ;; + "EV5 (21164)") + UNAME_MACHINE="alphaev5" ;; + "EV5.6 (21164A)") + UNAME_MACHINE="alphaev56" ;; + "EV5.6 (21164PC)") + UNAME_MACHINE="alphapca56" ;; + "EV5.7 (21164PC)") + UNAME_MACHINE="alphapca57" ;; + "EV6 (21264)") + UNAME_MACHINE="alphaev6" ;; + "EV6.7 (21264A)") + UNAME_MACHINE="alphaev67" ;; + "EV6.8CB (21264C)") + UNAME_MACHINE="alphaev68" ;; + "EV6.8AL (21264B)") + UNAME_MACHINE="alphaev68" ;; + "EV6.8CX (21264D)") + UNAME_MACHINE="alphaev68" ;; + "EV6.9A (21264/EV69A)") + UNAME_MACHINE="alphaev69" ;; + "EV7 (21364)") + UNAME_MACHINE="alphaev7" ;; + "EV7.9 (21364A)") + UNAME_MACHINE="alphaev79" ;; + esac + # A Pn.n version is a patched version. + # A Vn.n version is a released version. + # A Tn.n version is a released field test version. + # A Xn.n version is an unreleased experimental baselevel. + # 1.2 uses "1.2" for uname -r. + echo ${UNAME_MACHINE}-dec-osf`echo ${UNAME_RELEASE} | sed -e 's/^[PVTX]//' | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz'` + exit ;; + Alpha\ *:Windows_NT*:*) + # How do we know it's Interix rather than the generic POSIX subsystem? + # Should we change UNAME_MACHINE based on the output of uname instead + # of the specific Alpha model? + echo alpha-pc-interix + exit ;; + 21064:Windows_NT:50:3) + echo alpha-dec-winnt3.5 + exit ;; + Amiga*:UNIX_System_V:4.0:*) + echo m68k-unknown-sysv4 + exit ;; + *:[Aa]miga[Oo][Ss]:*:*) + echo ${UNAME_MACHINE}-unknown-amigaos + exit ;; + *:[Mm]orph[Oo][Ss]:*:*) + echo ${UNAME_MACHINE}-unknown-morphos + exit ;; + *:OS/390:*:*) + echo i370-ibm-openedition + exit ;; + *:z/VM:*:*) + echo s390-ibm-zvmoe + exit ;; + *:OS400:*:*) + echo powerpc-ibm-os400 + exit ;; + arm:RISC*:1.[012]*:*|arm:riscix:1.[012]*:*) + echo arm-acorn-riscix${UNAME_RELEASE} + exit ;; + arm:riscos:*:*|arm:RISCOS:*:*) + echo arm-unknown-riscos + exit ;; + SR2?01:HI-UX/MPP:*:* | SR8000:HI-UX/MPP:*:*) + echo hppa1.1-hitachi-hiuxmpp + exit ;; + Pyramid*:OSx*:*:* | MIS*:OSx*:*:* | MIS*:SMP_DC-OSx*:*:*) + # akee@wpdis03.wpafb.af.mil (Earle F. Ake) contributed MIS and NILE. + if test "`(/bin/universe) 2>/dev/null`" = att ; then + echo pyramid-pyramid-sysv3 + else + echo pyramid-pyramid-bsd + fi + exit ;; + NILE*:*:*:dcosx) + echo pyramid-pyramid-svr4 + exit ;; + DRS?6000:unix:4.0:6*) + echo sparc-icl-nx6 + exit ;; + DRS?6000:UNIX_SV:4.2*:7* | DRS?6000:isis:4.2*:7*) + case `/usr/bin/uname -p` in + sparc) echo sparc-icl-nx7; exit ;; + esac ;; + s390x:SunOS:*:*) + echo ${UNAME_MACHINE}-ibm-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` + exit ;; + sun4H:SunOS:5.*:*) + echo sparc-hal-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` + exit ;; + sun4*:SunOS:5.*:* | tadpole*:SunOS:5.*:*) + echo sparc-sun-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` + exit ;; + i86pc:SunOS:5.*:* | i86xen:SunOS:5.*:*) + eval $set_cc_for_build + SUN_ARCH="i386" + # If there is a compiler, see if it is configured for 64-bit objects. + # Note that the Sun cc does not turn __LP64__ into 1 like gcc does. + # This test works for both compilers. + if [ "$CC_FOR_BUILD" != 'no_compiler_found' ]; then + if (echo '#ifdef __amd64'; echo IS_64BIT_ARCH; echo '#endif') | \ + (CCOPTS= $CC_FOR_BUILD -E - 2>/dev/null) | \ + grep IS_64BIT_ARCH >/dev/null + then + SUN_ARCH="x86_64" + fi + fi + echo ${SUN_ARCH}-pc-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` + exit ;; + sun4*:SunOS:6*:*) + # According to config.sub, this is the proper way to canonicalize + # SunOS6. Hard to guess exactly what SunOS6 will be like, but + # it's likely to be more like Solaris than SunOS4. + echo sparc-sun-solaris3`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` + exit ;; + sun4*:SunOS:*:*) + case "`/usr/bin/arch -k`" in + Series*|S4*) + UNAME_RELEASE=`uname -v` + ;; + esac + # Japanese Language versions have a version number like `4.1.3-JL'. + echo sparc-sun-sunos`echo ${UNAME_RELEASE}|sed -e 's/-/_/'` + exit ;; + sun3*:SunOS:*:*) + echo m68k-sun-sunos${UNAME_RELEASE} + exit ;; + sun*:*:4.2BSD:*) + UNAME_RELEASE=`(sed 1q /etc/motd | awk '{print substr($5,1,3)}') 2>/dev/null` + test "x${UNAME_RELEASE}" = "x" && UNAME_RELEASE=3 + case "`/bin/arch`" in + sun3) + echo m68k-sun-sunos${UNAME_RELEASE} + ;; + sun4) + echo sparc-sun-sunos${UNAME_RELEASE} + ;; + esac + exit ;; + aushp:SunOS:*:*) + echo sparc-auspex-sunos${UNAME_RELEASE} + exit ;; + # The situation for MiNT is a little confusing. The machine name + # can be virtually everything (everything which is not + # "atarist" or "atariste" at least should have a processor + # > m68000). The system name ranges from "MiNT" over "FreeMiNT" + # to the lowercase version "mint" (or "freemint"). Finally + # the system name "TOS" denotes a system which is actually not + # MiNT. But MiNT is downward compatible to TOS, so this should + # be no problem. + atarist[e]:*MiNT:*:* | atarist[e]:*mint:*:* | atarist[e]:*TOS:*:*) + echo m68k-atari-mint${UNAME_RELEASE} + exit ;; + atari*:*MiNT:*:* | atari*:*mint:*:* | atarist[e]:*TOS:*:*) + echo m68k-atari-mint${UNAME_RELEASE} + exit ;; + *falcon*:*MiNT:*:* | *falcon*:*mint:*:* | *falcon*:*TOS:*:*) + echo m68k-atari-mint${UNAME_RELEASE} + exit ;; + milan*:*MiNT:*:* | milan*:*mint:*:* | *milan*:*TOS:*:*) + echo m68k-milan-mint${UNAME_RELEASE} + exit ;; + hades*:*MiNT:*:* | hades*:*mint:*:* | *hades*:*TOS:*:*) + echo m68k-hades-mint${UNAME_RELEASE} + exit ;; + *:*MiNT:*:* | *:*mint:*:* | *:*TOS:*:*) + echo m68k-unknown-mint${UNAME_RELEASE} + exit ;; + m68k:machten:*:*) + echo m68k-apple-machten${UNAME_RELEASE} + exit ;; + powerpc:machten:*:*) + echo powerpc-apple-machten${UNAME_RELEASE} + exit ;; + RISC*:Mach:*:*) + echo mips-dec-mach_bsd4.3 + exit ;; + RISC*:ULTRIX:*:*) + echo mips-dec-ultrix${UNAME_RELEASE} + exit ;; + VAX*:ULTRIX*:*:*) + echo vax-dec-ultrix${UNAME_RELEASE} + exit ;; + 2020:CLIX:*:* | 2430:CLIX:*:*) + echo clipper-intergraph-clix${UNAME_RELEASE} + exit ;; + mips:*:*:UMIPS | mips:*:*:RISCos) + eval $set_cc_for_build + sed 's/^ //' << EOF >$dummy.c +#ifdef __cplusplus +#include <stdio.h> /* for printf() prototype */ + int main (int argc, char *argv[]) { +#else + int main (argc, argv) int argc; char *argv[]; { +#endif + #if defined (host_mips) && defined (MIPSEB) + #if defined (SYSTYPE_SYSV) + printf ("mips-mips-riscos%ssysv\n", argv[1]); exit (0); + #endif + #if defined (SYSTYPE_SVR4) + printf ("mips-mips-riscos%ssvr4\n", argv[1]); exit (0); + #endif + #if defined (SYSTYPE_BSD43) || defined(SYSTYPE_BSD) + printf ("mips-mips-riscos%sbsd\n", argv[1]); exit (0); + #endif + #endif + exit (-1); + } +EOF + $CC_FOR_BUILD -o $dummy $dummy.c && + dummyarg=`echo "${UNAME_RELEASE}" | sed -n 's/\([0-9]*\).*/\1/p'` && + SYSTEM_NAME=`$dummy $dummyarg` && + { echo "$SYSTEM_NAME"; exit; } + echo mips-mips-riscos${UNAME_RELEASE} + exit ;; + Motorola:PowerMAX_OS:*:*) + echo powerpc-motorola-powermax + exit ;; + Motorola:*:4.3:PL8-*) + echo powerpc-harris-powermax + exit ;; + Night_Hawk:*:*:PowerMAX_OS | Synergy:PowerMAX_OS:*:*) + echo powerpc-harris-powermax + exit ;; + Night_Hawk:Power_UNIX:*:*) + echo powerpc-harris-powerunix + exit ;; + m88k:CX/UX:7*:*) + echo m88k-harris-cxux7 + exit ;; + m88k:*:4*:R4*) + echo m88k-motorola-sysv4 + exit ;; + m88k:*:3*:R3*) + echo m88k-motorola-sysv3 + exit ;; + AViiON:dgux:*:*) + # DG/UX returns AViiON for all architectures + UNAME_PROCESSOR=`/usr/bin/uname -p` + if [ $UNAME_PROCESSOR = mc88100 ] || [ $UNAME_PROCESSOR = mc88110 ] + then + if [ ${TARGET_BINARY_INTERFACE}x = m88kdguxelfx ] || \ + [ ${TARGET_BINARY_INTERFACE}x = x ] + then + echo m88k-dg-dgux${UNAME_RELEASE} + else + echo m88k-dg-dguxbcs${UNAME_RELEASE} + fi + else + echo i586-dg-dgux${UNAME_RELEASE} + fi + exit ;; + M88*:DolphinOS:*:*) # DolphinOS (SVR3) + echo m88k-dolphin-sysv3 + exit ;; + M88*:*:R3*:*) + # Delta 88k system running SVR3 + echo m88k-motorola-sysv3 + exit ;; + XD88*:*:*:*) # Tektronix XD88 system running UTekV (SVR3) + echo m88k-tektronix-sysv3 + exit ;; + Tek43[0-9][0-9]:UTek:*:*) # Tektronix 4300 system running UTek (BSD) + echo m68k-tektronix-bsd + exit ;; + *:IRIX*:*:*) + echo mips-sgi-irix`echo ${UNAME_RELEASE}|sed -e 's/-/_/g'` + exit ;; + ????????:AIX?:[12].1:2) # AIX 2.2.1 or AIX 2.1.1 is RT/PC AIX. + echo romp-ibm-aix # uname -m gives an 8 hex-code CPU id + exit ;; # Note that: echo "'`uname -s`'" gives 'AIX ' + i*86:AIX:*:*) + echo i386-ibm-aix + exit ;; + ia64:AIX:*:*) + if [ -x /usr/bin/oslevel ] ; then + IBM_REV=`/usr/bin/oslevel` + else + IBM_REV=${UNAME_VERSION}.${UNAME_RELEASE} + fi + echo ${UNAME_MACHINE}-ibm-aix${IBM_REV} + exit ;; + *:AIX:2:3) + if grep bos325 /usr/include/stdio.h >/dev/null 2>&1; then + eval $set_cc_for_build + sed 's/^ //' << EOF >$dummy.c + #include <sys/systemcfg.h> + + main() + { + if (!__power_pc()) + exit(1); + puts("powerpc-ibm-aix3.2.5"); + exit(0); + } +EOF + if $CC_FOR_BUILD -o $dummy $dummy.c && SYSTEM_NAME=`$dummy` + then + echo "$SYSTEM_NAME" + else + echo rs6000-ibm-aix3.2.5 + fi + elif grep bos324 /usr/include/stdio.h >/dev/null 2>&1; then + echo rs6000-ibm-aix3.2.4 + else + echo rs6000-ibm-aix3.2 + fi + exit ;; + *:AIX:*:[456]) + IBM_CPU_ID=`/usr/sbin/lsdev -C -c processor -S available | sed 1q | awk '{ print $1 }'` + if /usr/sbin/lsattr -El ${IBM_CPU_ID} | grep ' POWER' >/dev/null 2>&1; then + IBM_ARCH=rs6000 + else + IBM_ARCH=powerpc + fi + if [ -x /usr/bin/oslevel ] ; then + IBM_REV=`/usr/bin/oslevel` + else + IBM_REV=${UNAME_VERSION}.${UNAME_RELEASE} + fi + echo ${IBM_ARCH}-ibm-aix${IBM_REV} + exit ;; + *:AIX:*:*) + echo rs6000-ibm-aix + exit ;; + ibmrt:4.4BSD:*|romp-ibm:BSD:*) + echo romp-ibm-bsd4.4 + exit ;; + ibmrt:*BSD:*|romp-ibm:BSD:*) # covers RT/PC BSD and + echo romp-ibm-bsd${UNAME_RELEASE} # 4.3 with uname added to + exit ;; # report: romp-ibm BSD 4.3 + *:BOSX:*:*) + echo rs6000-bull-bosx + exit ;; + DPX/2?00:B.O.S.:*:*) + echo m68k-bull-sysv3 + exit ;; + 9000/[34]??:4.3bsd:1.*:*) + echo m68k-hp-bsd + exit ;; + hp300:4.4BSD:*:* | 9000/[34]??:4.3bsd:2.*:*) + echo m68k-hp-bsd4.4 + exit ;; + 9000/[34678]??:HP-UX:*:*) + HPUX_REV=`echo ${UNAME_RELEASE}|sed -e 's/[^.]*.[0B]*//'` + case "${UNAME_MACHINE}" in + 9000/31? ) HP_ARCH=m68000 ;; + 9000/[34]?? ) HP_ARCH=m68k ;; + 9000/[678][0-9][0-9]) + if [ -x /usr/bin/getconf ]; then + sc_cpu_version=`/usr/bin/getconf SC_CPU_VERSION 2>/dev/null` + sc_kernel_bits=`/usr/bin/getconf SC_KERNEL_BITS 2>/dev/null` + case "${sc_cpu_version}" in + 523) HP_ARCH="hppa1.0" ;; # CPU_PA_RISC1_0 + 528) HP_ARCH="hppa1.1" ;; # CPU_PA_RISC1_1 + 532) # CPU_PA_RISC2_0 + case "${sc_kernel_bits}" in + 32) HP_ARCH="hppa2.0n" ;; + 64) HP_ARCH="hppa2.0w" ;; + '') HP_ARCH="hppa2.0" ;; # HP-UX 10.20 + esac ;; + esac + fi + if [ "${HP_ARCH}" = "" ]; then + eval $set_cc_for_build + sed 's/^ //' << EOF >$dummy.c + + #define _HPUX_SOURCE + #include <stdlib.h> + #include <unistd.h> + + int main () + { + #if defined(_SC_KERNEL_BITS) + long bits = sysconf(_SC_KERNEL_BITS); + #endif + long cpu = sysconf (_SC_CPU_VERSION); + + switch (cpu) + { + case CPU_PA_RISC1_0: puts ("hppa1.0"); break; + case CPU_PA_RISC1_1: puts ("hppa1.1"); break; + case CPU_PA_RISC2_0: + #if defined(_SC_KERNEL_BITS) + switch (bits) + { + case 64: puts ("hppa2.0w"); break; + case 32: puts ("hppa2.0n"); break; + default: puts ("hppa2.0"); break; + } break; + #else /* !defined(_SC_KERNEL_BITS) */ + puts ("hppa2.0"); break; + #endif + default: puts ("hppa1.0"); break; + } + exit (0); + } +EOF + (CCOPTS= $CC_FOR_BUILD -o $dummy $dummy.c 2>/dev/null) && HP_ARCH=`$dummy` + test -z "$HP_ARCH" && HP_ARCH=hppa + fi ;; + esac + if [ ${HP_ARCH} = "hppa2.0w" ] + then + eval $set_cc_for_build + + # hppa2.0w-hp-hpux* has a 64-bit kernel and a compiler generating + # 32-bit code. hppa64-hp-hpux* has the same kernel and a compiler + # generating 64-bit code. GNU and HP use different nomenclature: + # + # $ CC_FOR_BUILD=cc ./config.guess + # => hppa2.0w-hp-hpux11.23 + # $ CC_FOR_BUILD="cc +DA2.0w" ./config.guess + # => hppa64-hp-hpux11.23 + + if echo __LP64__ | (CCOPTS= $CC_FOR_BUILD -E - 2>/dev/null) | + grep -q __LP64__ + then + HP_ARCH="hppa2.0w" + else + HP_ARCH="hppa64" + fi + fi + echo ${HP_ARCH}-hp-hpux${HPUX_REV} + exit ;; + ia64:HP-UX:*:*) + HPUX_REV=`echo ${UNAME_RELEASE}|sed -e 's/[^.]*.[0B]*//'` + echo ia64-hp-hpux${HPUX_REV} + exit ;; + 3050*:HI-UX:*:*) + eval $set_cc_for_build + sed 's/^ //' << EOF >$dummy.c + #include <unistd.h> + int + main () + { + long cpu = sysconf (_SC_CPU_VERSION); + /* The order matters, because CPU_IS_HP_MC68K erroneously returns + true for CPU_PA_RISC1_0. CPU_IS_PA_RISC returns correct + results, however. */ + if (CPU_IS_PA_RISC (cpu)) + { + switch (cpu) + { + case CPU_PA_RISC1_0: puts ("hppa1.0-hitachi-hiuxwe2"); break; + case CPU_PA_RISC1_1: puts ("hppa1.1-hitachi-hiuxwe2"); break; + case CPU_PA_RISC2_0: puts ("hppa2.0-hitachi-hiuxwe2"); break; + default: puts ("hppa-hitachi-hiuxwe2"); break; + } + } + else if (CPU_IS_HP_MC68K (cpu)) + puts ("m68k-hitachi-hiuxwe2"); + else puts ("unknown-hitachi-hiuxwe2"); + exit (0); + } +EOF + $CC_FOR_BUILD -o $dummy $dummy.c && SYSTEM_NAME=`$dummy` && + { echo "$SYSTEM_NAME"; exit; } + echo unknown-hitachi-hiuxwe2 + exit ;; + 9000/7??:4.3bsd:*:* | 9000/8?[79]:4.3bsd:*:* ) + echo hppa1.1-hp-bsd + exit ;; + 9000/8??:4.3bsd:*:*) + echo hppa1.0-hp-bsd + exit ;; + *9??*:MPE/iX:*:* | *3000*:MPE/iX:*:*) + echo hppa1.0-hp-mpeix + exit ;; + hp7??:OSF1:*:* | hp8?[79]:OSF1:*:* ) + echo hppa1.1-hp-osf + exit ;; + hp8??:OSF1:*:*) + echo hppa1.0-hp-osf + exit ;; + i*86:OSF1:*:*) + if [ -x /usr/sbin/sysversion ] ; then + echo ${UNAME_MACHINE}-unknown-osf1mk + else + echo ${UNAME_MACHINE}-unknown-osf1 + fi + exit ;; + parisc*:Lites*:*:*) + echo hppa1.1-hp-lites + exit ;; + C1*:ConvexOS:*:* | convex:ConvexOS:C1*:*) + echo c1-convex-bsd + exit ;; + C2*:ConvexOS:*:* | convex:ConvexOS:C2*:*) + if getsysinfo -f scalar_acc + then echo c32-convex-bsd + else echo c2-convex-bsd + fi + exit ;; + C34*:ConvexOS:*:* | convex:ConvexOS:C34*:*) + echo c34-convex-bsd + exit ;; + C38*:ConvexOS:*:* | convex:ConvexOS:C38*:*) + echo c38-convex-bsd + exit ;; + C4*:ConvexOS:*:* | convex:ConvexOS:C4*:*) + echo c4-convex-bsd + exit ;; + CRAY*Y-MP:*:*:*) + echo ymp-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' + exit ;; + CRAY*[A-Z]90:*:*:*) + echo ${UNAME_MACHINE}-cray-unicos${UNAME_RELEASE} \ + | sed -e 's/CRAY.*\([A-Z]90\)/\1/' \ + -e y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/ \ + -e 's/\.[^.]*$/.X/' + exit ;; + CRAY*TS:*:*:*) + echo t90-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' + exit ;; + CRAY*T3E:*:*:*) + echo alphaev5-cray-unicosmk${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' + exit ;; + CRAY*SV1:*:*:*) + echo sv1-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' + exit ;; + *:UNICOS/mp:*:*) + echo craynv-cray-unicosmp${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' + exit ;; + F30[01]:UNIX_System_V:*:* | F700:UNIX_System_V:*:*) + FUJITSU_PROC=`uname -m | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz'` + FUJITSU_SYS=`uname -p | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/\///'` + FUJITSU_REL=`echo ${UNAME_RELEASE} | sed -e 's/ /_/'` + echo "${FUJITSU_PROC}-fujitsu-${FUJITSU_SYS}${FUJITSU_REL}" + exit ;; + 5000:UNIX_System_V:4.*:*) + FUJITSU_SYS=`uname -p | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/\///'` + FUJITSU_REL=`echo ${UNAME_RELEASE} | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/ /_/'` + echo "sparc-fujitsu-${FUJITSU_SYS}${FUJITSU_REL}" + exit ;; + i*86:BSD/386:*:* | i*86:BSD/OS:*:* | *:Ascend\ Embedded/OS:*:*) + echo ${UNAME_MACHINE}-pc-bsdi${UNAME_RELEASE} + exit ;; + sparc*:BSD/OS:*:*) + echo sparc-unknown-bsdi${UNAME_RELEASE} + exit ;; + *:BSD/OS:*:*) + echo ${UNAME_MACHINE}-unknown-bsdi${UNAME_RELEASE} + exit ;; + *:FreeBSD:*:*) + case ${UNAME_MACHINE} in + pc98) + echo i386-unknown-freebsd`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'` ;; + amd64) + echo x86_64-unknown-freebsd`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'` ;; + *) + echo ${UNAME_MACHINE}-unknown-freebsd`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'` ;; + esac + exit ;; + i*:CYGWIN*:*) + echo ${UNAME_MACHINE}-pc-cygwin + exit ;; + *:MINGW*:*) + echo ${UNAME_MACHINE}-pc-mingw32 + exit ;; + i*:windows32*:*) + # uname -m includes "-pc" on this system. + echo ${UNAME_MACHINE}-mingw32 + exit ;; + i*:PW*:*) + echo ${UNAME_MACHINE}-pc-pw32 + exit ;; + *:Interix*:[3456]*) + case ${UNAME_MACHINE} in + x86) + echo i586-pc-interix${UNAME_RELEASE} + exit ;; + EM64T | authenticamd | genuineintel) + echo x86_64-unknown-interix${UNAME_RELEASE} + exit ;; + IA64) + echo ia64-unknown-interix${UNAME_RELEASE} + exit ;; + esac ;; + [345]86:Windows_95:* | [345]86:Windows_98:* | [345]86:Windows_NT:*) + echo i${UNAME_MACHINE}-pc-mks + exit ;; + 8664:Windows_NT:*) + echo x86_64-pc-mks + exit ;; + i*:Windows_NT*:* | Pentium*:Windows_NT*:*) + # How do we know it's Interix rather than the generic POSIX subsystem? + # It also conflicts with pre-2.0 versions of AT&T UWIN. Should we + # UNAME_MACHINE based on the output of uname instead of i386? + echo i586-pc-interix + exit ;; + i*:UWIN*:*) + echo ${UNAME_MACHINE}-pc-uwin + exit ;; + amd64:CYGWIN*:*:* | x86_64:CYGWIN*:*:*) + echo x86_64-unknown-cygwin + exit ;; + p*:CYGWIN*:*) + echo powerpcle-unknown-cygwin + exit ;; + prep*:SunOS:5.*:*) + echo powerpcle-unknown-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` + exit ;; + *:GNU:*:*) + # the GNU system + echo `echo ${UNAME_MACHINE}|sed -e 's,[-/].*$,,'`-unknown-gnu`echo ${UNAME_RELEASE}|sed -e 's,/.*$,,'` + exit ;; + *:GNU/*:*:*) + # other systems with GNU libc and userland + echo ${UNAME_MACHINE}-unknown-`echo ${UNAME_SYSTEM} | sed 's,^[^/]*/,,' | tr '[A-Z]' '[a-z]'``echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'`-gnu + exit ;; + i*86:Minix:*:*) + echo ${UNAME_MACHINE}-pc-minix + exit ;; + alpha:Linux:*:*) + case `sed -n '/^cpu model/s/^.*: \(.*\)/\1/p' < /proc/cpuinfo` in + EV5) UNAME_MACHINE=alphaev5 ;; + EV56) UNAME_MACHINE=alphaev56 ;; + PCA56) UNAME_MACHINE=alphapca56 ;; + PCA57) UNAME_MACHINE=alphapca56 ;; + EV6) UNAME_MACHINE=alphaev6 ;; + EV67) UNAME_MACHINE=alphaev67 ;; + EV68*) UNAME_MACHINE=alphaev68 ;; + esac + objdump --private-headers /bin/sh | grep -q ld.so.1 + if test "$?" = 0 ; then LIBC="libc1" ; else LIBC="" ; fi + echo ${UNAME_MACHINE}-unknown-linux-gnu${LIBC} + exit ;; + arm*:Linux:*:*) + eval $set_cc_for_build + if echo __ARM_EABI__ | $CC_FOR_BUILD -E - 2>/dev/null \ + | grep -q __ARM_EABI__ + then + echo ${UNAME_MACHINE}-unknown-linux-gnu + else + echo ${UNAME_MACHINE}-unknown-linux-gnueabi + fi + exit ;; + avr32*:Linux:*:*) + echo ${UNAME_MACHINE}-unknown-linux-gnu + exit ;; + cris:Linux:*:*) + echo cris-axis-linux-gnu + exit ;; + crisv32:Linux:*:*) + echo crisv32-axis-linux-gnu + exit ;; + frv:Linux:*:*) + echo frv-unknown-linux-gnu + exit ;; + i*86:Linux:*:*) + echo ${UNAME_MACHINE}-pc-linux-gnu + exit ;; + ia64:Linux:*:*) + echo ${UNAME_MACHINE}-unknown-linux-gnu + exit ;; + m32r*:Linux:*:*) + echo ${UNAME_MACHINE}-unknown-linux-gnu + exit ;; + m68*:Linux:*:*) + echo ${UNAME_MACHINE}-unknown-linux-gnu + exit ;; + mips:Linux:*:* | mips64:Linux:*:*) + eval $set_cc_for_build + sed 's/^ //' << EOF >$dummy.c + #undef CPU + #undef ${UNAME_MACHINE} + #undef ${UNAME_MACHINE}el + #if defined(__MIPSEL__) || defined(__MIPSEL) || defined(_MIPSEL) || defined(MIPSEL) + CPU=${UNAME_MACHINE}el + #else + #if defined(__MIPSEB__) || defined(__MIPSEB) || defined(_MIPSEB) || defined(MIPSEB) + CPU=${UNAME_MACHINE} + #else + CPU= + #endif + #endif +EOF + eval "`$CC_FOR_BUILD -E $dummy.c 2>/dev/null | sed -n ' + /^CPU/{ + s: ::g + p + }'`" + test x"${CPU}" != x && { echo "${CPU}-unknown-linux-gnu"; exit; } + ;; + or32:Linux:*:*) + echo or32-unknown-linux-gnu + exit ;; + padre:Linux:*:*) + echo sparc-unknown-linux-gnu + exit ;; + parisc64:Linux:*:* | hppa64:Linux:*:*) + echo hppa64-unknown-linux-gnu + exit ;; + parisc:Linux:*:* | hppa:Linux:*:*) + # Look for CPU level + case `grep '^cpu[^a-z]*:' /proc/cpuinfo 2>/dev/null | cut -d' ' -f2` in + PA7*) echo hppa1.1-unknown-linux-gnu ;; + PA8*) echo hppa2.0-unknown-linux-gnu ;; + *) echo hppa-unknown-linux-gnu ;; + esac + exit ;; + ppc64:Linux:*:*) + echo powerpc64-unknown-linux-gnu + exit ;; + ppc:Linux:*:*) + echo powerpc-unknown-linux-gnu + exit ;; + s390:Linux:*:* | s390x:Linux:*:*) + echo ${UNAME_MACHINE}-ibm-linux + exit ;; + sh64*:Linux:*:*) + echo ${UNAME_MACHINE}-unknown-linux-gnu + exit ;; + sh*:Linux:*:*) + echo ${UNAME_MACHINE}-unknown-linux-gnu + exit ;; + sparc:Linux:*:* | sparc64:Linux:*:*) + echo ${UNAME_MACHINE}-unknown-linux-gnu + exit ;; + vax:Linux:*:*) + echo ${UNAME_MACHINE}-dec-linux-gnu + exit ;; + x86_64:Linux:*:*) + echo x86_64-unknown-linux-gnu + exit ;; + xtensa*:Linux:*:*) + echo ${UNAME_MACHINE}-unknown-linux-gnu + exit ;; + i*86:DYNIX/ptx:4*:*) + # ptx 4.0 does uname -s correctly, with DYNIX/ptx in there. + # earlier versions are messed up and put the nodename in both + # sysname and nodename. + echo i386-sequent-sysv4 + exit ;; + i*86:UNIX_SV:4.2MP:2.*) + # Unixware is an offshoot of SVR4, but it has its own version + # number series starting with 2... + # I am not positive that other SVR4 systems won't match this, + # I just have to hope. -- rms. + # Use sysv4.2uw... so that sysv4* matches it. + echo ${UNAME_MACHINE}-pc-sysv4.2uw${UNAME_VERSION} + exit ;; + i*86:OS/2:*:*) + # If we were able to find `uname', then EMX Unix compatibility + # is probably installed. + echo ${UNAME_MACHINE}-pc-os2-emx + exit ;; + i*86:XTS-300:*:STOP) + echo ${UNAME_MACHINE}-unknown-stop + exit ;; + i*86:atheos:*:*) + echo ${UNAME_MACHINE}-unknown-atheos + exit ;; + i*86:syllable:*:*) + echo ${UNAME_MACHINE}-pc-syllable + exit ;; + i*86:LynxOS:2.*:* | i*86:LynxOS:3.[01]*:* | i*86:LynxOS:4.[02]*:*) + echo i386-unknown-lynxos${UNAME_RELEASE} + exit ;; + i*86:*DOS:*:*) + echo ${UNAME_MACHINE}-pc-msdosdjgpp + exit ;; + i*86:*:4.*:* | i*86:SYSTEM_V:4.*:*) + UNAME_REL=`echo ${UNAME_RELEASE} | sed 's/\/MP$//'` + if grep Novell /usr/include/link.h >/dev/null 2>/dev/null; then + echo ${UNAME_MACHINE}-univel-sysv${UNAME_REL} + else + echo ${UNAME_MACHINE}-pc-sysv${UNAME_REL} + fi + exit ;; + i*86:*:5:[678]*) + # UnixWare 7.x, OpenUNIX and OpenServer 6. + case `/bin/uname -X | grep "^Machine"` in + *486*) UNAME_MACHINE=i486 ;; + *Pentium) UNAME_MACHINE=i586 ;; + *Pent*|*Celeron) UNAME_MACHINE=i686 ;; + esac + echo ${UNAME_MACHINE}-unknown-sysv${UNAME_RELEASE}${UNAME_SYSTEM}${UNAME_VERSION} + exit ;; + i*86:*:3.2:*) + if test -f /usr/options/cb.name; then + UNAME_REL=`sed -n 's/.*Version //p' </usr/options/cb.name` + echo ${UNAME_MACHINE}-pc-isc$UNAME_REL + elif /bin/uname -X 2>/dev/null >/dev/null ; then + UNAME_REL=`(/bin/uname -X|grep Release|sed -e 's/.*= //')` + (/bin/uname -X|grep i80486 >/dev/null) && UNAME_MACHINE=i486 + (/bin/uname -X|grep '^Machine.*Pentium' >/dev/null) \ + && UNAME_MACHINE=i586 + (/bin/uname -X|grep '^Machine.*Pent *II' >/dev/null) \ + && UNAME_MACHINE=i686 + (/bin/uname -X|grep '^Machine.*Pentium Pro' >/dev/null) \ + && UNAME_MACHINE=i686 + echo ${UNAME_MACHINE}-pc-sco$UNAME_REL + else + echo ${UNAME_MACHINE}-pc-sysv32 + fi + exit ;; + pc:*:*:*) + # Left here for compatibility: + # uname -m prints for DJGPP always 'pc', but it prints nothing about + # the processor, so we play safe by assuming i586. + # Note: whatever this is, it MUST be the same as what config.sub + # prints for the "djgpp" host, or else GDB configury will decide that + # this is a cross-build. + echo i586-pc-msdosdjgpp + exit ;; + Intel:Mach:3*:*) + echo i386-pc-mach3 + exit ;; + paragon:*:*:*) + echo i860-intel-osf1 + exit ;; + i860:*:4.*:*) # i860-SVR4 + if grep Stardent /usr/include/sys/uadmin.h >/dev/null 2>&1 ; then + echo i860-stardent-sysv${UNAME_RELEASE} # Stardent Vistra i860-SVR4 + else # Add other i860-SVR4 vendors below as they are discovered. + echo i860-unknown-sysv${UNAME_RELEASE} # Unknown i860-SVR4 + fi + exit ;; + mini*:CTIX:SYS*5:*) + # "miniframe" + echo m68010-convergent-sysv + exit ;; + mc68k:UNIX:SYSTEM5:3.51m) + echo m68k-convergent-sysv + exit ;; + M680?0:D-NIX:5.3:*) + echo m68k-diab-dnix + exit ;; + M68*:*:R3V[5678]*:*) + test -r /sysV68 && { echo 'm68k-motorola-sysv'; exit; } ;; + 3[345]??:*:4.0:3.0 | 3[34]??A:*:4.0:3.0 | 3[34]??,*:*:4.0:3.0 | 3[34]??/*:*:4.0:3.0 | 4400:*:4.0:3.0 | 4850:*:4.0:3.0 | SKA40:*:4.0:3.0 | SDS2:*:4.0:3.0 | SHG2:*:4.0:3.0 | S7501*:*:4.0:3.0) + OS_REL='' + test -r /etc/.relid \ + && OS_REL=.`sed -n 's/[^ ]* [^ ]* \([0-9][0-9]\).*/\1/p' < /etc/.relid` + /bin/uname -p 2>/dev/null | grep 86 >/dev/null \ + && { echo i486-ncr-sysv4.3${OS_REL}; exit; } + /bin/uname -p 2>/dev/null | /bin/grep entium >/dev/null \ + && { echo i586-ncr-sysv4.3${OS_REL}; exit; } ;; + 3[34]??:*:4.0:* | 3[34]??,*:*:4.0:*) + /bin/uname -p 2>/dev/null | grep 86 >/dev/null \ + && { echo i486-ncr-sysv4; exit; } ;; + NCR*:*:4.2:* | MPRAS*:*:4.2:*) + OS_REL='.3' + test -r /etc/.relid \ + && OS_REL=.`sed -n 's/[^ ]* [^ ]* \([0-9][0-9]\).*/\1/p' < /etc/.relid` + /bin/uname -p 2>/dev/null | grep 86 >/dev/null \ + && { echo i486-ncr-sysv4.3${OS_REL}; exit; } + /bin/uname -p 2>/dev/null | /bin/grep entium >/dev/null \ + && { echo i586-ncr-sysv4.3${OS_REL}; exit; } + /bin/uname -p 2>/dev/null | /bin/grep pteron >/dev/null \ + && { echo i586-ncr-sysv4.3${OS_REL}; exit; } ;; + m68*:LynxOS:2.*:* | m68*:LynxOS:3.0*:*) + echo m68k-unknown-lynxos${UNAME_RELEASE} + exit ;; + mc68030:UNIX_System_V:4.*:*) + echo m68k-atari-sysv4 + exit ;; + TSUNAMI:LynxOS:2.*:*) + echo sparc-unknown-lynxos${UNAME_RELEASE} + exit ;; + rs6000:LynxOS:2.*:*) + echo rs6000-unknown-lynxos${UNAME_RELEASE} + exit ;; + PowerPC:LynxOS:2.*:* | PowerPC:LynxOS:3.[01]*:* | PowerPC:LynxOS:4.[02]*:*) + echo powerpc-unknown-lynxos${UNAME_RELEASE} + exit ;; + SM[BE]S:UNIX_SV:*:*) + echo mips-dde-sysv${UNAME_RELEASE} + exit ;; + RM*:ReliantUNIX-*:*:*) + echo mips-sni-sysv4 + exit ;; + RM*:SINIX-*:*:*) + echo mips-sni-sysv4 + exit ;; + *:SINIX-*:*:*) + if uname -p 2>/dev/null >/dev/null ; then + UNAME_MACHINE=`(uname -p) 2>/dev/null` + echo ${UNAME_MACHINE}-sni-sysv4 + else + echo ns32k-sni-sysv + fi + exit ;; + PENTIUM:*:4.0*:*) # Unisys `ClearPath HMP IX 4000' SVR4/MP effort + # says <Richard.M.Bartel@ccMail.Census.GOV> + echo i586-unisys-sysv4 + exit ;; + *:UNIX_System_V:4*:FTX*) + # From Gerald Hewes <hewes@openmarket.com>. + # How about differentiating between stratus architectures? -djm + echo hppa1.1-stratus-sysv4 + exit ;; + *:*:*:FTX*) + # From seanf@swdc.stratus.com. + echo i860-stratus-sysv4 + exit ;; + i*86:VOS:*:*) + # From Paul.Green@stratus.com. + echo ${UNAME_MACHINE}-stratus-vos + exit ;; + *:VOS:*:*) + # From Paul.Green@stratus.com. + echo hppa1.1-stratus-vos + exit ;; + mc68*:A/UX:*:*) + echo m68k-apple-aux${UNAME_RELEASE} + exit ;; + news*:NEWS-OS:6*:*) + echo mips-sony-newsos6 + exit ;; + R[34]000:*System_V*:*:* | R4000:UNIX_SYSV:*:* | R*000:UNIX_SV:*:*) + if [ -d /usr/nec ]; then + echo mips-nec-sysv${UNAME_RELEASE} + else + echo mips-unknown-sysv${UNAME_RELEASE} + fi + exit ;; + BeBox:BeOS:*:*) # BeOS running on hardware made by Be, PPC only. + echo powerpc-be-beos + exit ;; + BeMac:BeOS:*:*) # BeOS running on Mac or Mac clone, PPC only. + echo powerpc-apple-beos + exit ;; + BePC:BeOS:*:*) # BeOS running on Intel PC compatible. + echo i586-pc-beos + exit ;; + BePC:Haiku:*:*) # Haiku running on Intel PC compatible. + echo i586-pc-haiku + exit ;; + SX-4:SUPER-UX:*:*) + echo sx4-nec-superux${UNAME_RELEASE} + exit ;; + SX-5:SUPER-UX:*:*) + echo sx5-nec-superux${UNAME_RELEASE} + exit ;; + SX-6:SUPER-UX:*:*) + echo sx6-nec-superux${UNAME_RELEASE} + exit ;; + SX-7:SUPER-UX:*:*) + echo sx7-nec-superux${UNAME_RELEASE} + exit ;; + SX-8:SUPER-UX:*:*) + echo sx8-nec-superux${UNAME_RELEASE} + exit ;; + SX-8R:SUPER-UX:*:*) + echo sx8r-nec-superux${UNAME_RELEASE} + exit ;; + Power*:Rhapsody:*:*) + echo powerpc-apple-rhapsody${UNAME_RELEASE} + exit ;; + *:Rhapsody:*:*) + echo ${UNAME_MACHINE}-apple-rhapsody${UNAME_RELEASE} + exit ;; + *:Darwin:*:*) + UNAME_PROCESSOR=`uname -p` || UNAME_PROCESSOR=unknown + case $UNAME_PROCESSOR in + i386) + eval $set_cc_for_build + if [ "$CC_FOR_BUILD" != 'no_compiler_found' ]; then + if (echo '#ifdef __LP64__'; echo IS_64BIT_ARCH; echo '#endif') | \ + (CCOPTS= $CC_FOR_BUILD -E - 2>/dev/null) | \ + grep IS_64BIT_ARCH >/dev/null + then + UNAME_PROCESSOR="x86_64" + fi + fi ;; + unknown) UNAME_PROCESSOR=powerpc ;; + esac + echo ${UNAME_PROCESSOR}-apple-darwin${UNAME_RELEASE} + exit ;; + *:procnto*:*:* | *:QNX:[0123456789]*:*) + UNAME_PROCESSOR=`uname -p` + if test "$UNAME_PROCESSOR" = "x86"; then + UNAME_PROCESSOR=i386 + UNAME_MACHINE=pc + fi + echo ${UNAME_PROCESSOR}-${UNAME_MACHINE}-nto-qnx${UNAME_RELEASE} + exit ;; + *:QNX:*:4*) + echo i386-pc-qnx + exit ;; + NSE-?:NONSTOP_KERNEL:*:*) + echo nse-tandem-nsk${UNAME_RELEASE} + exit ;; + NSR-?:NONSTOP_KERNEL:*:*) + echo nsr-tandem-nsk${UNAME_RELEASE} + exit ;; + *:NonStop-UX:*:*) + echo mips-compaq-nonstopux + exit ;; + BS2000:POSIX*:*:*) + echo bs2000-siemens-sysv + exit ;; + DS/*:UNIX_System_V:*:*) + echo ${UNAME_MACHINE}-${UNAME_SYSTEM}-${UNAME_RELEASE} + exit ;; + *:Plan9:*:*) + # "uname -m" is not consistent, so use $cputype instead. 386 + # is converted to i386 for consistency with other x86 + # operating systems. + if test "$cputype" = "386"; then + UNAME_MACHINE=i386 + else + UNAME_MACHINE="$cputype" + fi + echo ${UNAME_MACHINE}-unknown-plan9 + exit ;; + *:TOPS-10:*:*) + echo pdp10-unknown-tops10 + exit ;; + *:TENEX:*:*) + echo pdp10-unknown-tenex + exit ;; + KS10:TOPS-20:*:* | KL10:TOPS-20:*:* | TYPE4:TOPS-20:*:*) + echo pdp10-dec-tops20 + exit ;; + XKL-1:TOPS-20:*:* | TYPE5:TOPS-20:*:*) + echo pdp10-xkl-tops20 + exit ;; + *:TOPS-20:*:*) + echo pdp10-unknown-tops20 + exit ;; + *:ITS:*:*) + echo pdp10-unknown-its + exit ;; + SEI:*:*:SEIUX) + echo mips-sei-seiux${UNAME_RELEASE} + exit ;; + *:DragonFly:*:*) + echo ${UNAME_MACHINE}-unknown-dragonfly`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'` + exit ;; + *:*VMS:*:*) + UNAME_MACHINE=`(uname -p) 2>/dev/null` + case "${UNAME_MACHINE}" in + A*) echo alpha-dec-vms ; exit ;; + I*) echo ia64-dec-vms ; exit ;; + V*) echo vax-dec-vms ; exit ;; + esac ;; + *:XENIX:*:SysV) + echo i386-pc-xenix + exit ;; + i*86:skyos:*:*) + echo ${UNAME_MACHINE}-pc-skyos`echo ${UNAME_RELEASE}` | sed -e 's/ .*$//' + exit ;; + i*86:rdos:*:*) + echo ${UNAME_MACHINE}-pc-rdos + exit ;; + i*86:AROS:*:*) + echo ${UNAME_MACHINE}-pc-aros + exit ;; +esac + +#echo '(No uname command or uname output not recognized.)' 1>&2 +#echo "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" 1>&2 + +eval $set_cc_for_build +cat >$dummy.c <<EOF +#ifdef _SEQUENT_ +# include <sys/types.h> +# include <sys/utsname.h> +#endif +main () +{ +#if defined (sony) +#if defined (MIPSEB) + /* BFD wants "bsd" instead of "newsos". Perhaps BFD should be changed, + I don't know.... */ + printf ("mips-sony-bsd\n"); exit (0); +#else +#include <sys/param.h> + printf ("m68k-sony-newsos%s\n", +#ifdef NEWSOS4 + "4" +#else + "" +#endif + ); exit (0); +#endif +#endif + +#if defined (__arm) && defined (__acorn) && defined (__unix) + printf ("arm-acorn-riscix\n"); exit (0); +#endif + +#if defined (hp300) && !defined (hpux) + printf ("m68k-hp-bsd\n"); exit (0); +#endif + +#if defined (NeXT) +#if !defined (__ARCHITECTURE__) +#define __ARCHITECTURE__ "m68k" +#endif + int version; + version=`(hostinfo | sed -n 's/.*NeXT Mach \([0-9]*\).*/\1/p') 2>/dev/null`; + if (version < 4) + printf ("%s-next-nextstep%d\n", __ARCHITECTURE__, version); + else + printf ("%s-next-openstep%d\n", __ARCHITECTURE__, version); + exit (0); +#endif + +#if defined (MULTIMAX) || defined (n16) +#if defined (UMAXV) + printf ("ns32k-encore-sysv\n"); exit (0); +#else +#if defined (CMU) + printf ("ns32k-encore-mach\n"); exit (0); +#else + printf ("ns32k-encore-bsd\n"); exit (0); +#endif +#endif +#endif + +#if defined (__386BSD__) + printf ("i386-pc-bsd\n"); exit (0); +#endif + +#if defined (sequent) +#if defined (i386) + printf ("i386-sequent-dynix\n"); exit (0); +#endif +#if defined (ns32000) + printf ("ns32k-sequent-dynix\n"); exit (0); +#endif +#endif + +#if defined (_SEQUENT_) + struct utsname un; + + uname(&un); + + if (strncmp(un.version, "V2", 2) == 0) { + printf ("i386-sequent-ptx2\n"); exit (0); + } + if (strncmp(un.version, "V1", 2) == 0) { /* XXX is V1 correct? */ + printf ("i386-sequent-ptx1\n"); exit (0); + } + printf ("i386-sequent-ptx\n"); exit (0); + +#endif + +#if defined (vax) +# if !defined (ultrix) +# include <sys/param.h> +# if defined (BSD) +# if BSD == 43 + printf ("vax-dec-bsd4.3\n"); exit (0); +# else +# if BSD == 199006 + printf ("vax-dec-bsd4.3reno\n"); exit (0); +# else + printf ("vax-dec-bsd\n"); exit (0); +# endif +# endif +# else + printf ("vax-dec-bsd\n"); exit (0); +# endif +# else + printf ("vax-dec-ultrix\n"); exit (0); +# endif +#endif + +#if defined (alliant) && defined (i860) + printf ("i860-alliant-bsd\n"); exit (0); +#endif + + exit (1); +} +EOF + +$CC_FOR_BUILD -o $dummy $dummy.c 2>/dev/null && SYSTEM_NAME=`$dummy` && + { echo "$SYSTEM_NAME"; exit; } + +# Apollos put the system type in the environment. + +test -d /usr/apollo && { echo ${ISP}-apollo-${SYSTYPE}; exit; } + +# Convex versions that predate uname can use getsysinfo(1) + +if [ -x /usr/convex/getsysinfo ] +then + case `getsysinfo -f cpu_type` in + c1*) + echo c1-convex-bsd + exit ;; + c2*) + if getsysinfo -f scalar_acc + then echo c32-convex-bsd + else echo c2-convex-bsd + fi + exit ;; + c34*) + echo c34-convex-bsd + exit ;; + c38*) + echo c38-convex-bsd + exit ;; + c4*) + echo c4-convex-bsd + exit ;; + esac +fi + +cat >&2 <<EOF +$0: unable to guess system type + +This script, last modified $timestamp, has failed to recognize +the operating system you are using. It is advised that you +download the most up to date version of the config scripts from + + http://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.guess;hb=HEAD +and + http://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.sub;hb=HEAD + +If the version you run ($0) is already up to date, please +send the following data and any information you think might be +pertinent to <config-patches@gnu.org> in order to provide the needed +information to handle your system. + +config.guess timestamp = $timestamp + +uname -m = `(uname -m) 2>/dev/null || echo unknown` +uname -r = `(uname -r) 2>/dev/null || echo unknown` +uname -s = `(uname -s) 2>/dev/null || echo unknown` +uname -v = `(uname -v) 2>/dev/null || echo unknown` + +/usr/bin/uname -p = `(/usr/bin/uname -p) 2>/dev/null` +/bin/uname -X = `(/bin/uname -X) 2>/dev/null` + +hostinfo = `(hostinfo) 2>/dev/null` +/bin/universe = `(/bin/universe) 2>/dev/null` +/usr/bin/arch -k = `(/usr/bin/arch -k) 2>/dev/null` +/bin/arch = `(/bin/arch) 2>/dev/null` +/usr/bin/oslevel = `(/usr/bin/oslevel) 2>/dev/null` +/usr/convex/getsysinfo = `(/usr/convex/getsysinfo) 2>/dev/null` + +UNAME_MACHINE = ${UNAME_MACHINE} +UNAME_RELEASE = ${UNAME_RELEASE} +UNAME_SYSTEM = ${UNAME_SYSTEM} +UNAME_VERSION = ${UNAME_VERSION} +EOF + +exit 1 + +# Local variables: +# eval: (add-hook 'write-file-hooks 'time-stamp) +# time-stamp-start: "timestamp='" +# time-stamp-format: "%:y-%02m-%02d" +# time-stamp-end: "'" +# End: diff --git a/build/system/config.sub b/build/system/config.sub new file mode 100755 index 0000000..5ecc18b --- /dev/null +++ b/build/system/config.sub @@ -0,0 +1,1700 @@ +#! /bin/sh +# Configuration validation subroutine script. +# Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, +# 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009 +# Free Software Foundation, Inc. + +timestamp='2009-10-07' + +# This file is (in principle) common to ALL GNU software. +# The presence of a machine in this file suggests that SOME GNU software +# can handle that machine. It does not imply ALL GNU software can. +# +# This file is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA +# 02110-1301, USA. +# +# As a special exception to the GNU General Public License, if you +# distribute this file as part of a program that contains a +# configuration script generated by Autoconf, you may include it under +# the same distribution terms that you use for the rest of that program. + + +# Please send patches to <config-patches@gnu.org>. Submit a context +# diff and a properly formatted GNU ChangeLog entry. +# +# Configuration subroutine to validate and canonicalize a configuration type. +# Supply the specified configuration type as an argument. +# If it is invalid, we print an error message on stderr and exit with code 1. +# Otherwise, we print the canonical config type on stdout and succeed. + +# You can get the latest version of this script from: +# http://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.sub;hb=HEAD + +# This file is supposed to be the same for all GNU packages +# and recognize all the CPU types, system types and aliases +# that are meaningful with *any* GNU software. +# Each package is responsible for reporting which valid configurations +# it does not support. The user should be able to distinguish +# a failure to support a valid configuration from a meaningless +# configuration. + +# The goal of this file is to map all the various variations of a given +# machine specification into a single specification in the form: +# CPU_TYPE-MANUFACTURER-OPERATING_SYSTEM +# or in some cases, the newer four-part form: +# CPU_TYPE-MANUFACTURER-KERNEL-OPERATING_SYSTEM +# It is wrong to echo any other type of specification. + +me=`echo "$0" | sed -e 's,.*/,,'` + +usage="\ +Usage: $0 [OPTION] CPU-MFR-OPSYS + $0 [OPTION] ALIAS + +Canonicalize a configuration name. + +Operation modes: + -h, --help print this help, then exit + -t, --time-stamp print date of last modification, then exit + -v, --version print version number, then exit + +Report bugs and patches to <config-patches@gnu.org>." + +version="\ +GNU config.sub ($timestamp) + +Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, +2002, 2003, 2004, 2005, 2006, 2007, 2008 Free Software Foundation, Inc. + +This is free software; see the source for copying conditions. There is NO +warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE." + +help=" +Try \`$me --help' for more information." + +# Parse command line +while test $# -gt 0 ; do + case $1 in + --time-stamp | --time* | -t ) + echo "$timestamp" ; exit ;; + --version | -v ) + echo "$version" ; exit ;; + --help | --h* | -h ) + echo "$usage"; exit ;; + -- ) # Stop option processing + shift; break ;; + - ) # Use stdin as input. + break ;; + -* ) + echo "$me: invalid option $1$help" + exit 1 ;; + + *local*) + # First pass through any local machine types. + echo $1 + exit ;; + + * ) + break ;; + esac +done + +case $# in + 0) echo "$me: missing argument$help" >&2 + exit 1;; + 1) ;; + *) echo "$me: too many arguments$help" >&2 + exit 1;; +esac + +# Separate what the user gave into CPU-COMPANY and OS or KERNEL-OS (if any). +# Here we must recognize all the valid KERNEL-OS combinations. +maybe_os=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\2/'` +case $maybe_os in + nto-qnx* | linux-gnu* | linux-dietlibc | linux-newlib* | linux-uclibc* | \ + uclinux-uclibc* | uclinux-gnu* | kfreebsd*-gnu* | knetbsd*-gnu* | netbsd*-gnu* | \ + kopensolaris*-gnu* | \ + storm-chaos* | os2-emx* | rtmk-nova*) + os=-$maybe_os + basic_machine=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\1/'` + ;; + *) + basic_machine=`echo $1 | sed 's/-[^-]*$//'` + if [ $basic_machine != $1 ] + then os=`echo $1 | sed 's/.*-/-/'` + else os=; fi + ;; +esac + +### Let's recognize common machines as not being operating systems so +### that things like config.sub decstation-3100 work. We also +### recognize some manufacturers as not being operating systems, so we +### can provide default operating systems below. +case $os in + -sun*os*) + # Prevent following clause from handling this invalid input. + ;; + -dec* | -mips* | -sequent* | -encore* | -pc532* | -sgi* | -sony* | \ + -att* | -7300* | -3300* | -delta* | -motorola* | -sun[234]* | \ + -unicom* | -ibm* | -next | -hp | -isi* | -apollo | -altos* | \ + -convergent* | -ncr* | -news | -32* | -3600* | -3100* | -hitachi* |\ + -c[123]* | -convex* | -sun | -crds | -omron* | -dg | -ultra | -tti* | \ + -harris | -dolphin | -highlevel | -gould | -cbm | -ns | -masscomp | \ + -apple | -axis | -knuth | -cray | -microblaze) + os= + basic_machine=$1 + ;; + -bluegene*) + os=-cnk + ;; + -sim | -cisco | -oki | -wec | -winbond) + os= + basic_machine=$1 + ;; + -scout) + ;; + -wrs) + os=-vxworks + basic_machine=$1 + ;; + -chorusos*) + os=-chorusos + basic_machine=$1 + ;; + -chorusrdb) + os=-chorusrdb + basic_machine=$1 + ;; + -hiux*) + os=-hiuxwe2 + ;; + -sco6) + os=-sco5v6 + basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` + ;; + -sco5) + os=-sco3.2v5 + basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` + ;; + -sco4) + os=-sco3.2v4 + basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` + ;; + -sco3.2.[4-9]*) + os=`echo $os | sed -e 's/sco3.2./sco3.2v/'` + basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` + ;; + -sco3.2v[4-9]*) + # Don't forget version if it is 3.2v4 or newer. + basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` + ;; + -sco5v6*) + # Don't forget version if it is 3.2v4 or newer. + basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` + ;; + -sco*) + os=-sco3.2v2 + basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` + ;; + -udk*) + basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` + ;; + -isc) + os=-isc2.2 + basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` + ;; + -clix*) + basic_machine=clipper-intergraph + ;; + -isc*) + basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` + ;; + -lynx*) + os=-lynxos + ;; + -ptx*) + basic_machine=`echo $1 | sed -e 's/86-.*/86-sequent/'` + ;; + -windowsnt*) + os=`echo $os | sed -e 's/windowsnt/winnt/'` + ;; + -psos*) + os=-psos + ;; + -mint | -mint[0-9]*) + basic_machine=m68k-atari + os=-mint + ;; +esac + +# Decode aliases for certain CPU-COMPANY combinations. +case $basic_machine in + # Recognize the basic CPU types without company name. + # Some are omitted here because they have special meanings below. + 1750a | 580 \ + | a29k \ + | alpha | alphaev[4-8] | alphaev56 | alphaev6[78] | alphapca5[67] \ + | alpha64 | alpha64ev[4-8] | alpha64ev56 | alpha64ev6[78] | alpha64pca5[67] \ + | am33_2.0 \ + | arc | arm | arm[bl]e | arme[lb] | armv[2345] | armv[345][lb] | avr | avr32 \ + | bfin \ + | c4x | clipper \ + | d10v | d30v | dlx | dsp16xx \ + | fido | fr30 | frv \ + | h8300 | h8500 | hppa | hppa1.[01] | hppa2.0 | hppa2.0[nw] | hppa64 \ + | i370 | i860 | i960 | ia64 \ + | ip2k | iq2000 \ + | lm32 \ + | m32c | m32r | m32rle | m68000 | m68k | m88k \ + | maxq | mb | microblaze | mcore | mep | metag \ + | mips | mipsbe | mipseb | mipsel | mipsle \ + | mips16 \ + | mips64 | mips64el \ + | mips64octeon | mips64octeonel \ + | mips64orion | mips64orionel \ + | mips64r5900 | mips64r5900el \ + | mips64vr | mips64vrel \ + | mips64vr4100 | mips64vr4100el \ + | mips64vr4300 | mips64vr4300el \ + | mips64vr5000 | mips64vr5000el \ + | mips64vr5900 | mips64vr5900el \ + | mipsisa32 | mipsisa32el \ + | mipsisa32r2 | mipsisa32r2el \ + | mipsisa64 | mipsisa64el \ + | mipsisa64r2 | mipsisa64r2el \ + | mipsisa64sb1 | mipsisa64sb1el \ + | mipsisa64sr71k | mipsisa64sr71kel \ + | mipstx39 | mipstx39el \ + | mn10200 | mn10300 \ + | moxie \ + | mt \ + | msp430 \ + | nios | nios2 \ + | ns16k | ns32k \ + | or32 \ + | pdp10 | pdp11 | pj | pjl \ + | powerpc | powerpc64 | powerpc64le | powerpcle | ppcbe \ + | pyramid \ + | rx \ + | score \ + | sh | sh[1234] | sh[24]a | sh[24]aeb | sh[23]e | sh[34]eb | sheb | shbe | shle | sh[1234]le | sh3ele \ + | sh64 | sh64le \ + | sparc | sparc64 | sparc64b | sparc64v | sparc86x | sparclet | sparclite \ + | sparcv8 | sparcv9 | sparcv9b | sparcv9v \ + | spu | strongarm \ + | tahoe | thumb | tic4x | tic80 | tron \ + | v850 | v850e \ + | we32k \ + | x86 | xc16x | xscale | xscalee[bl] | xstormy16 | xtensa \ + | z8k | z80) + basic_machine=$basic_machine-unknown + ;; + m6811 | m68hc11 | m6812 | m68hc12 | picochip) + # Motorola 68HC11/12. + basic_machine=$basic_machine-unknown + os=-none + ;; + m88110 | m680[12346]0 | m683?2 | m68360 | m5200 | v70 | w65 | z8k) + ;; + ms1) + basic_machine=mt-unknown + ;; + + # We use `pc' rather than `unknown' + # because (1) that's what they normally are, and + # (2) the word "unknown" tends to confuse beginning users. + i*86 | x86_64) + basic_machine=$basic_machine-pc + ;; + # Object if more than one company name word. + *-*-*) + echo Invalid configuration \`$1\': machine \`$basic_machine\' not recognized 1>&2 + exit 1 + ;; + # Recognize the basic CPU types with company name. + 580-* \ + | a29k-* \ + | alpha-* | alphaev[4-8]-* | alphaev56-* | alphaev6[78]-* \ + | alpha64-* | alpha64ev[4-8]-* | alpha64ev56-* | alpha64ev6[78]-* \ + | alphapca5[67]-* | alpha64pca5[67]-* | arc-* \ + | arm-* | armbe-* | armle-* | armeb-* | armv*-* \ + | avr-* | avr32-* \ + | bfin-* | bs2000-* \ + | c[123]* | c30-* | [cjt]90-* | c4x-* | c54x-* | c55x-* | c6x-* \ + | clipper-* | craynv-* | cydra-* \ + | d10v-* | d30v-* | dlx-* \ + | elxsi-* \ + | f30[01]-* | f700-* | fido-* | fr30-* | frv-* | fx80-* \ + | h8300-* | h8500-* \ + | hppa-* | hppa1.[01]-* | hppa2.0-* | hppa2.0[nw]-* | hppa64-* \ + | i*86-* | i860-* | i960-* | ia64-* \ + | ip2k-* | iq2000-* \ + | lm32-* \ + | m32c-* | m32r-* | m32rle-* \ + | m68000-* | m680[012346]0-* | m68360-* | m683?2-* | m68k-* \ + | m88110-* | m88k-* | maxq-* | mcore-* | metag-* | microblaze-* \ + | mips-* | mipsbe-* | mipseb-* | mipsel-* | mipsle-* \ + | mips16-* \ + | mips64-* | mips64el-* \ + | mips64octeon-* | mips64octeonel-* \ + | mips64orion-* | mips64orionel-* \ + | mips64r5900-* | mips64r5900el-* \ + | mips64vr-* | mips64vrel-* \ + | mips64vr4100-* | mips64vr4100el-* \ + | mips64vr4300-* | mips64vr4300el-* \ + | mips64vr5000-* | mips64vr5000el-* \ + | mips64vr5900-* | mips64vr5900el-* \ + | mipsisa32-* | mipsisa32el-* \ + | mipsisa32r2-* | mipsisa32r2el-* \ + | mipsisa64-* | mipsisa64el-* \ + | mipsisa64r2-* | mipsisa64r2el-* \ + | mipsisa64sb1-* | mipsisa64sb1el-* \ + | mipsisa64sr71k-* | mipsisa64sr71kel-* \ + | mipstx39-* | mipstx39el-* \ + | mmix-* \ + | mt-* \ + | msp430-* \ + | nios-* | nios2-* \ + | none-* | np1-* | ns16k-* | ns32k-* \ + | orion-* \ + | pdp10-* | pdp11-* | pj-* | pjl-* | pn-* | power-* \ + | powerpc-* | powerpc64-* | powerpc64le-* | powerpcle-* | ppcbe-* \ + | pyramid-* \ + | romp-* | rs6000-* | rx-* \ + | sh-* | sh[1234]-* | sh[24]a-* | sh[24]aeb-* | sh[23]e-* | sh[34]eb-* | sheb-* | shbe-* \ + | shle-* | sh[1234]le-* | sh3ele-* | sh64-* | sh64le-* \ + | sparc-* | sparc64-* | sparc64b-* | sparc64v-* | sparc86x-* | sparclet-* \ + | sparclite-* \ + | sparcv8-* | sparcv9-* | sparcv9b-* | sparcv9v-* | strongarm-* | sv1-* | sx?-* \ + | tahoe-* | thumb-* \ + | tic30-* | tic4x-* | tic54x-* | tic55x-* | tic6x-* | tic80-* | tile-* \ + | tron-* \ + | v850-* | v850e-* | vax-* \ + | we32k-* \ + | x86-* | x86_64-* | xc16x-* | xps100-* | xscale-* | xscalee[bl]-* \ + | xstormy16-* | xtensa*-* \ + | ymp-* \ + | z8k-* | z80-*) + ;; + # Recognize the basic CPU types without company name, with glob match. + xtensa*) + basic_machine=$basic_machine-unknown + ;; + # Recognize the various machine names and aliases which stand + # for a CPU type and a company and sometimes even an OS. + 386bsd) + basic_machine=i386-unknown + os=-bsd + ;; + 3b1 | 7300 | 7300-att | att-7300 | pc7300 | safari | unixpc) + basic_machine=m68000-att + ;; + 3b*) + basic_machine=we32k-att + ;; + a29khif) + basic_machine=a29k-amd + os=-udi + ;; + abacus) + basic_machine=abacus-unknown + ;; + adobe68k) + basic_machine=m68010-adobe + os=-scout + ;; + alliant | fx80) + basic_machine=fx80-alliant + ;; + altos | altos3068) + basic_machine=m68k-altos + ;; + am29k) + basic_machine=a29k-none + os=-bsd + ;; + amd64) + basic_machine=x86_64-pc + ;; + amd64-*) + basic_machine=x86_64-`echo $basic_machine | sed 's/^[^-]*-//'` + ;; + amdahl) + basic_machine=580-amdahl + os=-sysv + ;; + amiga | amiga-*) + basic_machine=m68k-unknown + ;; + amigaos | amigados) + basic_machine=m68k-unknown + os=-amigaos + ;; + amigaunix | amix) + basic_machine=m68k-unknown + os=-sysv4 + ;; + apollo68) + basic_machine=m68k-apollo + os=-sysv + ;; + apollo68bsd) + basic_machine=m68k-apollo + os=-bsd + ;; + aros) + basic_machine=i386-pc + os=-aros + ;; + aux) + basic_machine=m68k-apple + os=-aux + ;; + balance) + basic_machine=ns32k-sequent + os=-dynix + ;; + blackfin) + basic_machine=bfin-unknown + os=-linux + ;; + blackfin-*) + basic_machine=bfin-`echo $basic_machine | sed 's/^[^-]*-//'` + os=-linux + ;; + bluegene*) + basic_machine=powerpc-ibm + os=-cnk + ;; + c90) + basic_machine=c90-cray + os=-unicos + ;; + cegcc) + basic_machine=arm-unknown + os=-cegcc + ;; + convex-c1) + basic_machine=c1-convex + os=-bsd + ;; + convex-c2) + basic_machine=c2-convex + os=-bsd + ;; + convex-c32) + basic_machine=c32-convex + os=-bsd + ;; + convex-c34) + basic_machine=c34-convex + os=-bsd + ;; + convex-c38) + basic_machine=c38-convex + os=-bsd + ;; + cray | j90) + basic_machine=j90-cray + os=-unicos + ;; + craynv) + basic_machine=craynv-cray + os=-unicosmp + ;; + cr16) + basic_machine=cr16-unknown + os=-elf + ;; + crds | unos) + basic_machine=m68k-crds + ;; + crisv32 | crisv32-* | etraxfs*) + basic_machine=crisv32-axis + ;; + cris | cris-* | etrax*) + basic_machine=cris-axis + ;; + crx) + basic_machine=crx-unknown + os=-elf + ;; + da30 | da30-*) + basic_machine=m68k-da30 + ;; + decstation | decstation-3100 | pmax | pmax-* | pmin | dec3100 | decstatn) + basic_machine=mips-dec + ;; + decsystem10* | dec10*) + basic_machine=pdp10-dec + os=-tops10 + ;; + decsystem20* | dec20*) + basic_machine=pdp10-dec + os=-tops20 + ;; + delta | 3300 | motorola-3300 | motorola-delta \ + | 3300-motorola | delta-motorola) + basic_machine=m68k-motorola + ;; + delta88) + basic_machine=m88k-motorola + os=-sysv3 + ;; + dicos) + basic_machine=i686-pc + os=-dicos + ;; + djgpp) + basic_machine=i586-pc + os=-msdosdjgpp + ;; + dpx20 | dpx20-*) + basic_machine=rs6000-bull + os=-bosx + ;; + dpx2* | dpx2*-bull) + basic_machine=m68k-bull + os=-sysv3 + ;; + ebmon29k) + basic_machine=a29k-amd + os=-ebmon + ;; + elxsi) + basic_machine=elxsi-elxsi + os=-bsd + ;; + encore | umax | mmax) + basic_machine=ns32k-encore + ;; + es1800 | OSE68k | ose68k | ose | OSE) + basic_machine=m68k-ericsson + os=-ose + ;; + fx2800) + basic_machine=i860-alliant + ;; + genix) + basic_machine=ns32k-ns + ;; + gmicro) + basic_machine=tron-gmicro + os=-sysv + ;; + go32) + basic_machine=i386-pc + os=-go32 + ;; + h3050r* | hiux*) + basic_machine=hppa1.1-hitachi + os=-hiuxwe2 + ;; + h8300hms) + basic_machine=h8300-hitachi + os=-hms + ;; + h8300xray) + basic_machine=h8300-hitachi + os=-xray + ;; + h8500hms) + basic_machine=h8500-hitachi + os=-hms + ;; + harris) + basic_machine=m88k-harris + os=-sysv3 + ;; + hp300-*) + basic_machine=m68k-hp + ;; + hp300bsd) + basic_machine=m68k-hp + os=-bsd + ;; + hp300hpux) + basic_machine=m68k-hp + os=-hpux + ;; + hp3k9[0-9][0-9] | hp9[0-9][0-9]) + basic_machine=hppa1.0-hp + ;; + hp9k2[0-9][0-9] | hp9k31[0-9]) + basic_machine=m68000-hp + ;; + hp9k3[2-9][0-9]) + basic_machine=m68k-hp + ;; + hp9k6[0-9][0-9] | hp6[0-9][0-9]) + basic_machine=hppa1.0-hp + ;; + hp9k7[0-79][0-9] | hp7[0-79][0-9]) + basic_machine=hppa1.1-hp + ;; + hp9k78[0-9] | hp78[0-9]) + # FIXME: really hppa2.0-hp + basic_machine=hppa1.1-hp + ;; + hp9k8[67]1 | hp8[67]1 | hp9k80[24] | hp80[24] | hp9k8[78]9 | hp8[78]9 | hp9k893 | hp893) + # FIXME: really hppa2.0-hp + basic_machine=hppa1.1-hp + ;; + hp9k8[0-9][13679] | hp8[0-9][13679]) + basic_machine=hppa1.1-hp + ;; + hp9k8[0-9][0-9] | hp8[0-9][0-9]) + basic_machine=hppa1.0-hp + ;; + hppa-next) + os=-nextstep3 + ;; + hppaosf) + basic_machine=hppa1.1-hp + os=-osf + ;; + hppro) + basic_machine=hppa1.1-hp + os=-proelf + ;; + i370-ibm* | ibm*) + basic_machine=i370-ibm + ;; +# I'm not sure what "Sysv32" means. Should this be sysv3.2? + i*86v32) + basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'` + os=-sysv32 + ;; + i*86v4*) + basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'` + os=-sysv4 + ;; + i*86v) + basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'` + os=-sysv + ;; + i*86sol2) + basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'` + os=-solaris2 + ;; + i386mach) + basic_machine=i386-mach + os=-mach + ;; + i386-vsta | vsta) + basic_machine=i386-unknown + os=-vsta + ;; + iris | iris4d) + basic_machine=mips-sgi + case $os in + -irix*) + ;; + *) + os=-irix4 + ;; + esac + ;; + isi68 | isi) + basic_machine=m68k-isi + os=-sysv + ;; + m68knommu) + basic_machine=m68k-unknown + os=-linux + ;; + m68knommu-*) + basic_machine=m68k-`echo $basic_machine | sed 's/^[^-]*-//'` + os=-linux + ;; + m88k-omron*) + basic_machine=m88k-omron + ;; + magnum | m3230) + basic_machine=mips-mips + os=-sysv + ;; + merlin) + basic_machine=ns32k-utek + os=-sysv + ;; + microblaze) + basic_machine=microblaze-xilinx + ;; + mingw32) + basic_machine=i386-pc + os=-mingw32 + ;; + mingw32ce) + basic_machine=arm-unknown + os=-mingw32ce + ;; + miniframe) + basic_machine=m68000-convergent + ;; + *mint | -mint[0-9]* | *MiNT | *MiNT[0-9]*) + basic_machine=m68k-atari + os=-mint + ;; + mips3*-*) + basic_machine=`echo $basic_machine | sed -e 's/mips3/mips64/'` + ;; + mips3*) + basic_machine=`echo $basic_machine | sed -e 's/mips3/mips64/'`-unknown + ;; + monitor) + basic_machine=m68k-rom68k + os=-coff + ;; + morphos) + basic_machine=powerpc-unknown + os=-morphos + ;; + msdos) + basic_machine=i386-pc + os=-msdos + ;; + ms1-*) + basic_machine=`echo $basic_machine | sed -e 's/ms1-/mt-/'` + ;; + mvs) + basic_machine=i370-ibm + os=-mvs + ;; + ncr3000) + basic_machine=i486-ncr + os=-sysv4 + ;; + netbsd386) + basic_machine=i386-unknown + os=-netbsd + ;; + netwinder) + basic_machine=armv4l-rebel + os=-linux + ;; + news | news700 | news800 | news900) + basic_machine=m68k-sony + os=-newsos + ;; + news1000) + basic_machine=m68030-sony + os=-newsos + ;; + news-3600 | risc-news) + basic_machine=mips-sony + os=-newsos + ;; + necv70) + basic_machine=v70-nec + os=-sysv + ;; + next | m*-next ) + basic_machine=m68k-next + case $os in + -nextstep* ) + ;; + -ns2*) + os=-nextstep2 + ;; + *) + os=-nextstep3 + ;; + esac + ;; + nh3000) + basic_machine=m68k-harris + os=-cxux + ;; + nh[45]000) + basic_machine=m88k-harris + os=-cxux + ;; + nindy960) + basic_machine=i960-intel + os=-nindy + ;; + mon960) + basic_machine=i960-intel + os=-mon960 + ;; + nonstopux) + basic_machine=mips-compaq + os=-nonstopux + ;; + np1) + basic_machine=np1-gould + ;; + nsr-tandem) + basic_machine=nsr-tandem + ;; + op50n-* | op60c-*) + basic_machine=hppa1.1-oki + os=-proelf + ;; + openrisc | openrisc-*) + basic_machine=or32-unknown + ;; + os400) + basic_machine=powerpc-ibm + os=-os400 + ;; + OSE68000 | ose68000) + basic_machine=m68000-ericsson + os=-ose + ;; + os68k) + basic_machine=m68k-none + os=-os68k + ;; + pa-hitachi) + basic_machine=hppa1.1-hitachi + os=-hiuxwe2 + ;; + paragon) + basic_machine=i860-intel + os=-osf + ;; + parisc) + basic_machine=hppa-unknown + os=-linux + ;; + parisc-*) + basic_machine=hppa-`echo $basic_machine | sed 's/^[^-]*-//'` + os=-linux + ;; + pbd) + basic_machine=sparc-tti + ;; + pbb) + basic_machine=m68k-tti + ;; + pc532 | pc532-*) + basic_machine=ns32k-pc532 + ;; + pc98) + basic_machine=i386-pc + ;; + pc98-*) + basic_machine=i386-`echo $basic_machine | sed 's/^[^-]*-//'` + ;; + pentium | p5 | k5 | k6 | nexgen | viac3) + basic_machine=i586-pc + ;; + pentiumpro | p6 | 6x86 | athlon | athlon_*) + basic_machine=i686-pc + ;; + pentiumii | pentium2 | pentiumiii | pentium3) + basic_machine=i686-pc + ;; + pentium4) + basic_machine=i786-pc + ;; + pentium-* | p5-* | k5-* | k6-* | nexgen-* | viac3-*) + basic_machine=i586-`echo $basic_machine | sed 's/^[^-]*-//'` + ;; + pentiumpro-* | p6-* | 6x86-* | athlon-*) + basic_machine=i686-`echo $basic_machine | sed 's/^[^-]*-//'` + ;; + pentiumii-* | pentium2-* | pentiumiii-* | pentium3-*) + basic_machine=i686-`echo $basic_machine | sed 's/^[^-]*-//'` + ;; + pentium4-*) + basic_machine=i786-`echo $basic_machine | sed 's/^[^-]*-//'` + ;; + pn) + basic_machine=pn-gould + ;; + power) basic_machine=power-ibm + ;; + ppc) basic_machine=powerpc-unknown + ;; + ppc-*) basic_machine=powerpc-`echo $basic_machine | sed 's/^[^-]*-//'` + ;; + ppcle | powerpclittle | ppc-le | powerpc-little) + basic_machine=powerpcle-unknown + ;; + ppcle-* | powerpclittle-*) + basic_machine=powerpcle-`echo $basic_machine | sed 's/^[^-]*-//'` + ;; + ppc64) basic_machine=powerpc64-unknown + ;; + ppc64-*) basic_machine=powerpc64-`echo $basic_machine | sed 's/^[^-]*-//'` + ;; + ppc64le | powerpc64little | ppc64-le | powerpc64-little) + basic_machine=powerpc64le-unknown + ;; + ppc64le-* | powerpc64little-*) + basic_machine=powerpc64le-`echo $basic_machine | sed 's/^[^-]*-//'` + ;; + ps2) + basic_machine=i386-ibm + ;; + pw32) + basic_machine=i586-unknown + os=-pw32 + ;; + rdos) + basic_machine=i386-pc + os=-rdos + ;; + rom68k) + basic_machine=m68k-rom68k + os=-coff + ;; + rm[46]00) + basic_machine=mips-siemens + ;; + rtpc | rtpc-*) + basic_machine=romp-ibm + ;; + s390 | s390-*) + basic_machine=s390-ibm + ;; + s390x | s390x-*) + basic_machine=s390x-ibm + ;; + sa29200) + basic_machine=a29k-amd + os=-udi + ;; + sb1) + basic_machine=mipsisa64sb1-unknown + ;; + sb1el) + basic_machine=mipsisa64sb1el-unknown + ;; + sde) + basic_machine=mipsisa32-sde + os=-elf + ;; + sei) + basic_machine=mips-sei + os=-seiux + ;; + sequent) + basic_machine=i386-sequent + ;; + sh) + basic_machine=sh-hitachi + os=-hms + ;; + sh5el) + basic_machine=sh5le-unknown + ;; + sh64) + basic_machine=sh64-unknown + ;; + sparclite-wrs | simso-wrs) + basic_machine=sparclite-wrs + os=-vxworks + ;; + sps7) + basic_machine=m68k-bull + os=-sysv2 + ;; + spur) + basic_machine=spur-unknown + ;; + st2000) + basic_machine=m68k-tandem + ;; + stratus) + basic_machine=i860-stratus + os=-sysv4 + ;; + sun2) + basic_machine=m68000-sun + ;; + sun2os3) + basic_machine=m68000-sun + os=-sunos3 + ;; + sun2os4) + basic_machine=m68000-sun + os=-sunos4 + ;; + sun3os3) + basic_machine=m68k-sun + os=-sunos3 + ;; + sun3os4) + basic_machine=m68k-sun + os=-sunos4 + ;; + sun4os3) + basic_machine=sparc-sun + os=-sunos3 + ;; + sun4os4) + basic_machine=sparc-sun + os=-sunos4 + ;; + sun4sol2) + basic_machine=sparc-sun + os=-solaris2 + ;; + sun3 | sun3-*) + basic_machine=m68k-sun + ;; + sun4) + basic_machine=sparc-sun + ;; + sun386 | sun386i | roadrunner) + basic_machine=i386-sun + ;; + sv1) + basic_machine=sv1-cray + os=-unicos + ;; + symmetry) + basic_machine=i386-sequent + os=-dynix + ;; + t3e) + basic_machine=alphaev5-cray + os=-unicos + ;; + t90) + basic_machine=t90-cray + os=-unicos + ;; + tic54x | c54x*) + basic_machine=tic54x-unknown + os=-coff + ;; + tic55x | c55x*) + basic_machine=tic55x-unknown + os=-coff + ;; + tic6x | c6x*) + basic_machine=tic6x-unknown + os=-coff + ;; + tile*) + basic_machine=tile-unknown + os=-linux-gnu + ;; + tx39) + basic_machine=mipstx39-unknown + ;; + tx39el) + basic_machine=mipstx39el-unknown + ;; + toad1) + basic_machine=pdp10-xkl + os=-tops20 + ;; + tower | tower-32) + basic_machine=m68k-ncr + ;; + tpf) + basic_machine=s390x-ibm + os=-tpf + ;; + udi29k) + basic_machine=a29k-amd + os=-udi + ;; + ultra3) + basic_machine=a29k-nyu + os=-sym1 + ;; + v810 | necv810) + basic_machine=v810-nec + os=-none + ;; + vaxv) + basic_machine=vax-dec + os=-sysv + ;; + vms) + basic_machine=vax-dec + os=-vms + ;; + vpp*|vx|vx-*) + basic_machine=f301-fujitsu + ;; + vxworks960) + basic_machine=i960-wrs + os=-vxworks + ;; + vxworks68) + basic_machine=m68k-wrs + os=-vxworks + ;; + vxworks29k) + basic_machine=a29k-wrs + os=-vxworks + ;; + w65*) + basic_machine=w65-wdc + os=-none + ;; + w89k-*) + basic_machine=hppa1.1-winbond + os=-proelf + ;; + xbox) + basic_machine=i686-pc + os=-mingw32 + ;; + xps | xps100) + basic_machine=xps100-honeywell + ;; + ymp) + basic_machine=ymp-cray + os=-unicos + ;; + z8k-*-coff) + basic_machine=z8k-unknown + os=-sim + ;; + z80-*-coff) + basic_machine=z80-unknown + os=-sim + ;; + none) + basic_machine=none-none + os=-none + ;; + +# Here we handle the default manufacturer of certain CPU types. It is in +# some cases the only manufacturer, in others, it is the most popular. + w89k) + basic_machine=hppa1.1-winbond + ;; + op50n) + basic_machine=hppa1.1-oki + ;; + op60c) + basic_machine=hppa1.1-oki + ;; + romp) + basic_machine=romp-ibm + ;; + mmix) + basic_machine=mmix-knuth + ;; + rs6000) + basic_machine=rs6000-ibm + ;; + vax) + basic_machine=vax-dec + ;; + pdp10) + # there are many clones, so DEC is not a safe bet + basic_machine=pdp10-unknown + ;; + pdp11) + basic_machine=pdp11-dec + ;; + we32k) + basic_machine=we32k-att + ;; + sh[1234] | sh[24]a | sh[24]aeb | sh[34]eb | sh[1234]le | sh[23]ele) + basic_machine=sh-unknown + ;; + sparc | sparcv8 | sparcv9 | sparcv9b | sparcv9v) + basic_machine=sparc-sun + ;; + cydra) + basic_machine=cydra-cydrome + ;; + orion) + basic_machine=orion-highlevel + ;; + orion105) + basic_machine=clipper-highlevel + ;; + mac | mpw | mac-mpw) + basic_machine=m68k-apple + ;; + pmac | pmac-mpw) + basic_machine=powerpc-apple + ;; + *-unknown) + # Make sure to match an already-canonicalized machine name. + ;; + *) + echo Invalid configuration \`$1\': machine \`$basic_machine\' not recognized 1>&2 + exit 1 + ;; +esac + +# Here we canonicalize certain aliases for manufacturers. +case $basic_machine in + *-digital*) + basic_machine=`echo $basic_machine | sed 's/digital.*/dec/'` + ;; + *-commodore*) + basic_machine=`echo $basic_machine | sed 's/commodore.*/cbm/'` + ;; + *) + ;; +esac + +# Decode manufacturer-specific aliases for certain operating systems. + +if [ x"$os" != x"" ] +then +case $os in + # First match some system type aliases + # that might get confused with valid system types. + # -solaris* is a basic system type, with this one exception. + -solaris1 | -solaris1.*) + os=`echo $os | sed -e 's|solaris1|sunos4|'` + ;; + -solaris) + os=-solaris2 + ;; + -svr4*) + os=-sysv4 + ;; + -unixware*) + os=-sysv4.2uw + ;; + -gnu/linux*) + os=`echo $os | sed -e 's|gnu/linux|linux-gnu|'` + ;; + # First accept the basic system types. + # The portable systems comes first. + # Each alternative MUST END IN A *, to match a version number. + # -sysv* is not here because it comes later, after sysvr4. + -gnu* | -bsd* | -mach* | -minix* | -genix* | -ultrix* | -irix* \ + | -*vms* | -sco* | -esix* | -isc* | -aix* | -cnk* | -sunos | -sunos[34]*\ + | -hpux* | -unos* | -osf* | -luna* | -dgux* | -solaris* | -sym* \ + | -kopensolaris* \ + | -amigaos* | -amigados* | -msdos* | -newsos* | -unicos* | -aof* \ + | -aos* | -aros* \ + | -nindy* | -vxsim* | -vxworks* | -ebmon* | -hms* | -mvs* \ + | -clix* | -riscos* | -uniplus* | -iris* | -rtu* | -xenix* \ + | -hiux* | -386bsd* | -knetbsd* | -mirbsd* | -netbsd* \ + | -openbsd* | -solidbsd* \ + | -ekkobsd* | -kfreebsd* | -freebsd* | -riscix* | -lynxos* \ + | -bosx* | -nextstep* | -cxux* | -aout* | -elf* | -oabi* \ + | -ptx* | -coff* | -ecoff* | -winnt* | -domain* | -vsta* \ + | -udi* | -eabi* | -lites* | -ieee* | -go32* | -aux* \ + | -chorusos* | -chorusrdb* | -cegcc* \ + | -cygwin* | -pe* | -psos* | -moss* | -proelf* | -rtems* \ + | -mingw32* | -linux-gnu* | -linux-newlib* | -linux-uclibc* \ + | -uxpv* | -beos* | -mpeix* | -udk* \ + | -interix* | -uwin* | -mks* | -rhapsody* | -darwin* | -opened* \ + | -openstep* | -oskit* | -conix* | -pw32* | -nonstopux* \ + | -storm-chaos* | -tops10* | -tenex* | -tops20* | -its* \ + | -os2* | -vos* | -palmos* | -uclinux* | -nucleus* \ + | -morphos* | -superux* | -rtmk* | -rtmk-nova* | -windiss* \ + | -powermax* | -dnix* | -nx6 | -nx7 | -sei* | -dragonfly* \ + | -skyos* | -haiku* | -rdos* | -toppers* | -drops* | -es*) + # Remember, each alternative MUST END IN *, to match a version number. + ;; + -qnx*) + case $basic_machine in + x86-* | i*86-*) + ;; + *) + os=-nto$os + ;; + esac + ;; + -nto-qnx*) + ;; + -nto*) + os=`echo $os | sed -e 's|nto|nto-qnx|'` + ;; + -sim | -es1800* | -hms* | -xray | -os68k* | -none* | -v88r* \ + | -windows* | -osx | -abug | -netware* | -os9* | -beos* | -haiku* \ + | -macos* | -mpw* | -magic* | -mmixware* | -mon960* | -lnews*) + ;; + -mac*) + os=`echo $os | sed -e 's|mac|macos|'` + ;; + -linux-dietlibc) + os=-linux-dietlibc + ;; + -linux*) + os=`echo $os | sed -e 's|linux|linux-gnu|'` + ;; + -sunos5*) + os=`echo $os | sed -e 's|sunos5|solaris2|'` + ;; + -sunos6*) + os=`echo $os | sed -e 's|sunos6|solaris3|'` + ;; + -opened*) + os=-openedition + ;; + -os400*) + os=-os400 + ;; + -wince*) + os=-wince + ;; + -osfrose*) + os=-osfrose + ;; + -osf*) + os=-osf + ;; + -utek*) + os=-bsd + ;; + -dynix*) + os=-bsd + ;; + -acis*) + os=-aos + ;; + -atheos*) + os=-atheos + ;; + -syllable*) + os=-syllable + ;; + -386bsd) + os=-bsd + ;; + -ctix* | -uts*) + os=-sysv + ;; + -nova*) + os=-rtmk-nova + ;; + -ns2 ) + os=-nextstep2 + ;; + -nsk*) + os=-nsk + ;; + # Preserve the version number of sinix5. + -sinix5.*) + os=`echo $os | sed -e 's|sinix|sysv|'` + ;; + -sinix*) + os=-sysv4 + ;; + -tpf*) + os=-tpf + ;; + -triton*) + os=-sysv3 + ;; + -oss*) + os=-sysv3 + ;; + -svr4) + os=-sysv4 + ;; + -svr3) + os=-sysv3 + ;; + -sysvr4) + os=-sysv4 + ;; + # This must come after -sysvr4. + -sysv*) + ;; + -ose*) + os=-ose + ;; + -es1800*) + os=-ose + ;; + -xenix) + os=-xenix + ;; + -*mint | -mint[0-9]* | -*MiNT | -MiNT[0-9]*) + os=-mint + ;; + -aros*) + os=-aros + ;; + -kaos*) + os=-kaos + ;; + -zvmoe) + os=-zvmoe + ;; + -dicos*) + os=-dicos + ;; + -none) + ;; + *) + # Get rid of the `-' at the beginning of $os. + os=`echo $os | sed 's/[^-]*-//'` + echo Invalid configuration \`$1\': system \`$os\' not recognized 1>&2 + exit 1 + ;; +esac +else + +# Here we handle the default operating systems that come with various machines. +# The value should be what the vendor currently ships out the door with their +# machine or put another way, the most popular os provided with the machine. + +# Note that if you're going to try to match "-MANUFACTURER" here (say, +# "-sun"), then you have to tell the case statement up towards the top +# that MANUFACTURER isn't an operating system. Otherwise, code above +# will signal an error saying that MANUFACTURER isn't an operating +# system, and we'll never get to this point. + +case $basic_machine in + score-*) + os=-elf + ;; + spu-*) + os=-elf + ;; + *-acorn) + os=-riscix1.2 + ;; + arm*-rebel) + os=-linux + ;; + arm*-semi) + os=-aout + ;; + c4x-* | tic4x-*) + os=-coff + ;; + # This must come before the *-dec entry. + pdp10-*) + os=-tops20 + ;; + pdp11-*) + os=-none + ;; + *-dec | vax-*) + os=-ultrix4.2 + ;; + m68*-apollo) + os=-domain + ;; + i386-sun) + os=-sunos4.0.2 + ;; + m68000-sun) + os=-sunos3 + # This also exists in the configure program, but was not the + # default. + # os=-sunos4 + ;; + m68*-cisco) + os=-aout + ;; + mep-*) + os=-elf + ;; + mips*-cisco) + os=-elf + ;; + mips*-*) + os=-elf + ;; + or32-*) + os=-coff + ;; + *-tti) # must be before sparc entry or we get the wrong os. + os=-sysv3 + ;; + sparc-* | *-sun) + os=-sunos4.1.1 + ;; + *-be) + os=-beos + ;; + *-haiku) + os=-haiku + ;; + *-ibm) + os=-aix + ;; + *-knuth) + os=-mmixware + ;; + *-wec) + os=-proelf + ;; + *-winbond) + os=-proelf + ;; + *-oki) + os=-proelf + ;; + *-hp) + os=-hpux + ;; + *-hitachi) + os=-hiux + ;; + i860-* | *-att | *-ncr | *-altos | *-motorola | *-convergent) + os=-sysv + ;; + *-cbm) + os=-amigaos + ;; + *-dg) + os=-dgux + ;; + *-dolphin) + os=-sysv3 + ;; + m68k-ccur) + os=-rtu + ;; + m88k-omron*) + os=-luna + ;; + *-next ) + os=-nextstep + ;; + *-sequent) + os=-ptx + ;; + *-crds) + os=-unos + ;; + *-ns) + os=-genix + ;; + i370-*) + os=-mvs + ;; + *-next) + os=-nextstep3 + ;; + *-gould) + os=-sysv + ;; + *-highlevel) + os=-bsd + ;; + *-encore) + os=-bsd + ;; + *-sgi) + os=-irix + ;; + *-siemens) + os=-sysv4 + ;; + *-masscomp) + os=-rtu + ;; + f30[01]-fujitsu | f700-fujitsu) + os=-uxpv + ;; + *-rom68k) + os=-coff + ;; + *-*bug) + os=-coff + ;; + *-apple) + os=-macos + ;; + *-atari*) + os=-mint + ;; + *) + os=-none + ;; +esac +fi + +# Here we handle the case where we know the os, and the CPU type, but not the +# manufacturer. We pick the logical manufacturer. +vendor=unknown +case $basic_machine in + *-unknown) + case $os in + -riscix*) + vendor=acorn + ;; + -sunos*) + vendor=sun + ;; + -cnk*|-aix*) + vendor=ibm + ;; + -beos*) + vendor=be + ;; + -hpux*) + vendor=hp + ;; + -mpeix*) + vendor=hp + ;; + -hiux*) + vendor=hitachi + ;; + -unos*) + vendor=crds + ;; + -dgux*) + vendor=dg + ;; + -luna*) + vendor=omron + ;; + -genix*) + vendor=ns + ;; + -mvs* | -opened*) + vendor=ibm + ;; + -os400*) + vendor=ibm + ;; + -ptx*) + vendor=sequent + ;; + -tpf*) + vendor=ibm + ;; + -vxsim* | -vxworks* | -windiss*) + vendor=wrs + ;; + -aux*) + vendor=apple + ;; + -hms*) + vendor=hitachi + ;; + -mpw* | -macos*) + vendor=apple + ;; + -*mint | -mint[0-9]* | -*MiNT | -MiNT[0-9]*) + vendor=atari + ;; + -vos*) + vendor=stratus + ;; + esac + basic_machine=`echo $basic_machine | sed "s/unknown/$vendor/"` + ;; +esac + +echo $basic_machine$os +exit + +# Local variables: +# eval: (add-hook 'write-file-hooks 'time-stamp) +# time-stamp-start: "timestamp='" +# time-stamp-format: "%:y-%02m-%02d" +# time-stamp-end: "'" +# End: diff --git a/build/system/configuration-rules.make b/build/system/configuration-rules.make new file mode 100644 index 0000000..b1aa605 --- /dev/null +++ b/build/system/configuration-rules.make @@ -0,0 +1,25 @@ +# file : build/system/configuration-rules.make +# author : Boris Kolpackov <boris@codesynthesis.com> +# copyright : Copyright (c) 2004-2010 Code Synthesis Tools CC +# license : GNU GPL v2; see accompanying LICENSE file + + +$(dcf_root)/system/configuration-dynamic.make: | $(dcf_root)/system/. + $(call message,,$(bld_root)/system/configure $@) + +ifeq ($(.DEFAULT_GOAL),$(dcf_root)/system/configuration-dynamic.make) +.DEFAULT_GOAL := +endif + + +ifndef %foreign% + +disfigure:: + $(call message,rm $(dcf_root)/system/configuration-dynamic.make,\ +rm -f $(dcf_root)/system/configuration-dynamic.make) + +ifeq ($(.DEFAULT_GOAL),disfigure) +.DEFAULT_GOAL := +endif + +endif diff --git a/build/system/configure b/build/system/configure new file mode 100755 index 0000000..621a12a --- /dev/null +++ b/build/system/configure @@ -0,0 +1,138 @@ +#! /usr/bin/env bash + +# file : build/system/configure +# author : Boris Kolpackov <boris@codesynthesis.com> +# copyright : Copyright (c) 2004-2010 Code Synthesis Tools CC +# license : GNU GPL v2; see accompanying LICENSE file + +# $1 out file +# +# bld_root - build root +# project_name - project name +# + +source $bld_root/dialog.bash + +$echo +$echo +$echo "configuring '$project_name'" +$echo +$echo + +# Build system. +# + +build=`$bld_root/system/config.guess` + +if [ $? != 0 ]; then + + $echo "unable to determine build system type" + exit 1 +fi + +$echo "build system is $build" + +build_cpu=`echo $build | cut -f 1 -d -` +build_mf=`echo $build | cut -f 2 -d -` +build_kernel=`echo $build | cut -f 3 -d -` +build_os=`echo $build | cut -f 4 -d -` + +if [ -z "$build_os" ]; then + + # Old format: cpu-mf-os + # + build_os=$build_kernel + build_kernel= +fi + + +# Host system. +# + +if [ -n "$host_system" ]; then + + host=`$bld_root/system/config.sub "$host_system"` + + if [ $? != 0 ]; then + + $echo "unable to canonicalize host system '$host_system'" + exit 1 + fi +else + host=$build +fi + +$echo "host system is $host" + +host_cpu=`echo $host | cut -f 1 -d -` +host_mf=`echo $host | cut -f 2 -d -` +host_kernel=`echo $host | cut -f 3 -d -` +host_os=`echo $host | cut -f 4 -d -` + +if [ -z "$host_os" ]; then + + # Old format: cpu-mf-os + # + host_os=$host_kernel + host_kernel= +fi + + +# Target system. +# +if [ -n "$target_system" ]; then + + target=`$bld_root/system/config.sub "$target_system"` + + if [ $? != 0 ]; then + + $echo "unable to canonicalize target system '$target_system'" + exit 1 + fi + + $echo "target system is $target" + + target_cpu=`echo $target | cut -f 1 -d -` + target_mf=`echo $target | cut -f 2 -d -` + target_kernel=`echo $target | cut -f 3 -d -` + target_os=`echo $target | cut -f 4 -d -` + + if [ -z "$target_os" ]; then + + # Old format: cpu-mf-os + # + target_os=$target_kernel + target_kernel= + fi + +else +target= +target_cpu= +target_mf= +target_kernel= +target_os= +fi + + + +# Write the configuration out. +# +echo "system_configuration := y" >$1 +echo >>$1 +echo "build_system := $build" >>$1 +echo "build_cpu := $build_cpu" >>$1 +echo "build_manufacturer := $build_mf" >>$1 +echo "build_os := $build_os" >>$1 +echo "build_kernel := $build_kernel" >>$1 +echo >>$1 +echo "host_system := $host" >>$1 +echo "host_cpu := $host_cpu" >>$1 +echo "host_manufacturer := $host_mf" >>$1 +echo "host_os := $host_os" >>$1 +echo "host_kernel := $host_kernel" >>$1 +echo >>$1 +echo "target_system := $target" >>$1 +echo "target_cpu := $target_cpu" >>$1 +echo "target_manufacturer := $target_mf" >>$1 +echo "target_os := $target_os" >>$1 +echo "target_kernel := $target_kernel" >>$1 diff --git a/documentation/BUGS b/documentation/BUGS new file mode 100644 index 0000000..ec499ae --- /dev/null +++ b/documentation/BUGS @@ -0,0 +1,18 @@ +@@ Messages during configuration should be about 80 chars long. + Right now they are much shorter which makes it look really ugly. + +@@ some keywords (l:) are being framed + +%% Relative paths result in rebuilds. + +@% When configuring with -j N some strange warnings appear. Temporary + fix. Depends on GNU make bug #12229. + +%% Use src_root path as default value for out_root. + +@@ Intel C++ does not generate phony rule for non-existent headers. + +@@ It seems to me that in generated header prefix logic the dependency + patched by sed script and one produced by a subsequent run of the + compiler are different which triggers makefile reload. I wonder + why?
\ No newline at end of file diff --git a/documentation/CLEANUP b/documentation/CLEANUP new file mode 100644 index 0000000..fc3e263 --- /dev/null +++ b/documentation/CLEANUP @@ -0,0 +1,2 @@ +%@ add project_name, add corresponding message to all configuration scripts +
\ No newline at end of file diff --git a/documentation/CONFIGURATION b/documentation/CONFIGURATION new file mode 100644 index 0000000..feed13c --- /dev/null +++ b/documentation/CONFIGURATION @@ -0,0 +1,64 @@ + +@@ It would be nice if configuration happens only when it is + required. For example if I need to build something that + uses CORBA then only in this case happens configuration of + CORBA facilities. + + +@@ 'configure' should depend on 'clean' + + +@@ What if I change something in config file (let's say archive to shared) + and then say make - things will break. + + +@@ It would be nice if I could keep build/ outside of the project. This + is going to be very useful when multiple projects share the same + build system. + +@@ it would be nice to have a project_base which will be + $(root)/example/project. However, in normal most cases project will be + the same as root, right? Look at CCF. Some comments: + + Saying -I$(root) would be exactly what I need if its value would be + .../example/project. This, according to the concept of clusters, could + be achived if I make .../example/project a cluster (which is quite + natural thing to do). It would also be a good example of a cluster. + + +@@ Right now I have one global implicit rule for the project. In most + cases this is probably enough. But what if I want to use different + rules for different sub-projects (config clusters). For example two + parts of the same project could use different compilers or ORB or... + Probably the generic approach would be to provide sub-dir specific + rules. + +@@ concept of configuration clusters (no more src_root). + + +@@ Can I get rid of src_root and out_root (i.e. can they be /)? + + +@@ It would be nice if I could configure the same sub-system + (like CORBA) for dirrefent parts of the project differenty. + + +@@ Do I really need those configuration clusters? Is the structure + of CCF right? Or am I just trying to hide problems of wrong + structuring? Isn't it overcomplication? Even if not shouldn't + I postpone this until I gain more experience? + +--------------------- + +@@ Each project includes (in its root directory) copy of the build system. + +@@ The build system is configuration cluster. + +@@ Configuration cluster sets src/out_root. + +@@ Configuration cluster can inherit configuration from its parent. + +@@ Configuration cluster can override inherited values. + +@@ sub-projects in configuration cluster should not refer to anything + outside of this cluster. diff --git a/documentation/DOC b/documentation/DOC new file mode 100644 index 0000000..0ace1cf --- /dev/null +++ b/documentation/DOC @@ -0,0 +1,16 @@ +@@ Update to describe new option importing mechanism. Maybe even + include some general model of project building? + + +@@ Create style section and put STYLE file there. + + +@@ Describe canonical targets (from targets). + +@@ Currently I have no description of targtes (e.g., nobody knows about + disfigure). + +@@ Update documentation with the new output from examples. + +@@ Add News section to the index.xhtml + diff --git a/documentation/FACILITIES b/documentation/FACILITIES new file mode 100644 index 0000000..26492f4 --- /dev/null +++ b/documentation/FACILITIES @@ -0,0 +1,16 @@ + +@@ can I have different strategies for src/out? Would I be able + to come up with generic implicit rules that work for all cases? + +@@ optional facilities could go into pre-load. + +@@ from building point of view distinction on source and generated + files is not essential. + +@@ Common places for generated files (from multi-arch): + + - home (out == src) + + - parallel structure outside (out is set based on curdir?) + + - subdirs in source (potentially many) (out := src + something) diff --git a/documentation/FEATURES b/documentation/FEATURES new file mode 100644 index 0000000..1068025 --- /dev/null +++ b/documentation/FEATURES @@ -0,0 +1,5 @@ +@@ Allow multiple files in $(call load ). + +@! Extract compiler-specific include paths to create do-nothing rules + for headers. + diff --git a/documentation/IDEAS b/documentation/IDEAS new file mode 100644 index 0000000..649f375 --- /dev/null +++ b/documentation/IDEAS @@ -0,0 +1,156 @@ +@@ Need to create some show-case with some intermidiate compiler like + idl/lex/yacc. M4 comes to mind. + +%% Stages of building + + 1. configure/configuration + + 2. build/build + + 3a. test/testing + + 3b. install/installation + +@@ Maybe I should have a special function for inclusion from special + directories (like Build). + +@@ it would nice to have suffixes configurable + +@@ There could be a set of files to configure building environment (like + suffixes of files, names of utilities, etc). If I decide to ship + environment as standalon product I will have to somehow separate + those files (like putting in different directories). + +@@ It would make sense to split build system on subsystems like 'base' + 'c' 'cxx', 'corba/cxx' etc. + +%% Maybe I should pre-load some commonly used patterns. + +@@ Maybe makefiles that are not ment to be used interactively should + inherit their interactivity status from their includer. + +@@ Allow changing of options based on the category (plus all). This + can be done like this: + + %.o : %.cpp : cxx_options = $(cxx_cpp_flags) $(cxx_debug_flags) $(cxx_diagnostic_flags) + %.o : %.cpp : cxx_cpp_options := + %.o : %.cpp : cxx_debug_options := -g + %.o : %.cpp : cxx_diagnostic_options := -Wall + + This will allow the user to change only what he want without much + hassle. + +@! Can I make a dependecy of lib.l on lib.so? Should I? Or should I list + .so/.a in the pattern rule so it gets deleted? + +@@ It would be nice to have a custom message for phony targets that merely + depend on normal targets. For example if I could get a list of targets + that were updated I would have been able to print such a message. This + would probably require modifications to make. + + For default target of a dispatch makefile (better name?) I use directory + name which makes perfect sense. BTW, maybe I should call them directory + makefiles, or meta-makefiles, or stubs? + +@@ Since the build of multiple goals in the same target can be tricky I + may want to detect this and give a warning/error (this could be + configurable). + +@@ 'cxx' should depend on 'c'. 'cxx' can reuse ar facility from 'c'. + +@@ Make function extension framework. The idea is to use $(shell) to call + arbitrary executable/shell-script. The only problem is that I need a + way to build something before continuing to read makefile. Something + like .REQUIRE: target? When make sees this it stops reading makefile + and tries to build the target. If build succeeded make resumes to + read the makefile. If build failed make stops with an error. + + The other, more advanced, idea is to use dynamic loading of functions. + This way it will be alot faster. + + If included makefiles could be rebuilt on the spot (i.e. without + first reading the rest) then it would be a way. + +@@ Can I use linker script instead of my .l library descriptor (or together + with?). + +@@ There is a support for 'version script' in ld. I wonder what is that. + +@@ study linux kernel build system + +@! Maybe clean/disfigure target should include deletion of a directory + if (a) the build could potentially create it and (b) it is empty. + This way things will be cleaner and, after saying make clean in the + build directory, one gets just configuration. + +@@ I can ask user if he wants to override default .a/.so search paths + (for example to match the compiler). + + +@@ Multidir example probably belongs to c subsystem. + +@@ If I have build-as-you-need-them makefile inclusion scheme then if I + include makefiles in a proper order I can get rid of those + 'configuring blah-blah' messages. + +@@ I can be cool and make 'ls' in cxx to find present c++ compilers. This + way I will be able to distribute compiler-specific files separately. + +@@ It would be nice to have include function that includes a file + relatevely to the current's Makefile directory. + +@@ Maybe factor out cpp as a common facility in 'c'? Right now I duplicate + some support code in cxx/gnu and cxx/intel. + +@@ All this '.l' abstraction support belongs to 'c'. + +@@ In import/export stubs check for version compatibilities. Oohooo! + +@@ What if I save src_root somewhere in out_root? + +%% Need to try to use build with distcc. Works well. + +@@ I may want to store src_root someweher in out_root so that I don't + need to ask for it (will not work in all cases). + +@! It is probably a good idea to make each file responsible for + making sure its guts are included right number of times. + +@! With introduction of .NOT_DEFAULT I can factor out aliasing into + (per-project) bootstrap.make. Did in some projects - works well. + Need to do them in example. + +@@ foreach is a way to define local variable. + +@! use $(< file) instead of cat + +@! use last dir + relative path in messages + +@! what about using few-letters vars instead of cxx_obj (o) cxx_od (d)? + +@! How about uniform importing facility without any subsystems? For example + CORBA is a translator and a library at the same time - how to handle it? + + - can use whatever names in imported files. + + - will need importing from project build dir and from bld_root + +@! Need to think about hacker mode - passing config info via command line + with standard names like CXX CPPFLAGS LDFLAGS, etc. + +@! teach import stubs to not try include anything when cleaning/disfiguring? + +@@ local target that will rebuild only local object files? Or maybe set an + order of rebuilding local files first? + +@! Now since I have .DEFAULT_TARGET I can do save/restore thing for export + import. So there won't be a need to secure default target. Way too cool! + +%% Usually src_root and out_root are the same. I should suggest one + by default when asking user for it. + +@@ There are two situations where I can guess src_root from out_root: + first is when out_root == src_root (I can check for build/bootstrap.make + though bootstrap.make can be named differently). The other case is when + out_root already contains build project (I will need to kind of marker + that contains value of src_root; maybe build/configuratio-dynamic.make). diff --git a/documentation/INSTALLATION b/documentation/INSTALLATION new file mode 100644 index 0000000..24eebcf --- /dev/null +++ b/documentation/INSTALLATION @@ -0,0 +1,5 @@ +%% used install -d to create directories during installation. + +%@ splitting, completion, and cleanup + +%% terse messages for installation commands. diff --git a/documentation/ISSUES b/documentation/ISSUES new file mode 100644 index 0000000..e7b4263 --- /dev/null +++ b/documentation/ISSUES @@ -0,0 +1,72 @@ +@@ use shell && instead of multi-line rules since they don't consider + atomic (e.g. if something failed other files won't be deleted). Or + maybe not, think about it (and read the doc). + +@@ Some implicit rule should actually be two rules: one that looks + for the source under srd_root tree and the other under out_root. + Theoretically, any source could be just an intermidiate file generated + from something else (discovered while playing with idl). + +@@ Compensating rules: 'clean all' example. + +@@ Issues from "Multi-Architecture Builds Using GNU make": + + - big (bloated) makefiles + + - cannot say "make foo.o" + +@@ How can I integrate building of realpath utility in configuration + process? + +@@ Executing make from non-source directory is painful. Can I make it + easier? + +%% When shared library is linked with absolute path the loader is looking + for the library with the same path. See also -soname= and -rpath ls + options. + +@@ With multidir makefiles I loos the ability to say make where I am. + This is especially nasty when I edit a file and then say make. This + happens for example in CCF. The easy workaround is to say something + "make -C dir/to/test/driver". Once this is done life get very nice. + Actually I think this could be the best approach. + +@@ Variable inheritance doesn't play well with 'make foo.o'. + +@@ Configurations include absolute paths to imported libraries which + makes it hard to reuse them. In this light configurations on installed + libraries should not include any absolute paths. + +@@ Better name for project_name? build_name? + +@@ Repetition of paths in $(call message) is quite ugly. Anything I can do? + +@@ -MP conflicts with --no-implicit-phony. The new approach uses a special + terminal pattern rule to handle this. However headers without suffix + cannot be handled by this method. + +@! Delete-on-error does not cover .o.d files. I could specify it as a target + together with .o but then it will try to rebuild it. + +@! When you hide things from make (like .o.d or .l/.so) all sorts of bad things + happen. + +@@ What is a better term for development (not installed?) build? + +@@ /usr/bin/g++ is a link but extracted include paths have precise version in + them (e.g. 3.3.4). But then dependencies will trigger update, right? + +@! I am using some of the features of GNU find which are not available in SUS. + +@@ Since .l.cpp-options pattern does not have any prereqs then the file can + always be created (example: I misspelled file name). + +@@ Use abspath to prevent call-inclusion from -I dirs. + +@@ lib.cpp-options should be lib.cpp_options? + +@@ Use $@ in $$(dir $(out)/%). + +@! Need to make content of .l compiler-independant (rpath stuff). + +@@ export is now position-sensitive. diff --git a/documentation/MAKE b/documentation/MAKE new file mode 100644 index 0000000..50e073b --- /dev/null +++ b/documentation/MAKE @@ -0,0 +1,31 @@ + +@@ I was thinking about the way make handles inclusion of missing + makefile. The following strategy seems like a better choice: + if makefile is missing try to rebuild & read it immediately, + without parsing the rest of makefile and without reexecuting + make later. This approach has at least two benefits: + + + more efficient (no make re-execution) (this is not very + important in most cases, thoug) + + + more deterministic: if some of the code after (missing) + included makefile depends on some code from it (for + example a function) then things can break (example: + configuration of ORB). + + - sequential (cannot build makefile in parallel) + + +@! target/pattern-specific vpath + +@@ no `target is up to date' message when commnds are executed + but target is not changed. + +@@ %.o %.d and include + +%% implicit double expansion: now supports target/pattern variables + and $- + +%% create `examples' directory where I can put md5 and maybe hello. + +@! shortest stem diff --git a/documentation/NOTES b/documentation/NOTES new file mode 100644 index 0000000..7bed2c8 --- /dev/null +++ b/documentation/NOTES @@ -0,0 +1,34 @@ +@@ ?= is deferred + +@@ automatically-generated dependecies should include absolute paths + just like gcc does. Note that it only happens when you pass gcc + absolute paths in -I so I should watch out! + +@@ order-only dependencies allow for elegant creation of a directory + before build. + +@@ need to try generation of headers in out_dir. + +@@ maybe think about shared library versioning. This could be done + transparently at installation time. + +%% I should use some form of include function for -include for + consistency. + +@@ linker accepts -O options and can opimize. + +@@ use suffix (.make, .cxx) to specify file type - not as a mere + separator. Can I use '-' as separator? Should I use '_' as separator? + +@@ read lisp ASDF manual. + +@@ Use $(eval foo:=bar) in rule's command to set variable only if (and after) + the rule is in use. + +%% Files in import directory are called configuration. They are not quite + that. Maybe a better name would be stub? + +@@ For some (all? SUS?) platforms inclusion of .so in .l is redundant + because .so is already linked against them. + +@@ Need to continue cleaning if some files do not exist (rm -f ?). diff --git a/documentation/OPTIMIZATION b/documentation/OPTIMIZATION new file mode 100644 index 0000000..dfdb06d --- /dev/null +++ b/documentation/OPTIMIZATION @@ -0,0 +1,21 @@ +%% I should keep a separate list of files that are included-once which + should also cache the realpaths. + +@@ It would make sense to use $(call include-once,out_dir) in cxx/cxx-o.make + etc. + +@@ Need to check what is being framed. + +@@ I wonder how much it costs to have the second expansion in implicit rule? + +@@ Make executes each line in a separate shell. I wonder if using && is + more efficient? + +%% check make's default hash table size. + +@@ would using `makefile: ' tecknique to prevent make from trying to + match against pattern-rules help? + +@@ Look for redundant $(eval ) calls (like I had in include-*). + +@@ use head -n 1 instead of sed -e 1q diff --git a/documentation/PROBLEMS b/documentation/PROBLEMS new file mode 100644 index 0000000..a07fbda --- /dev/null +++ b/documentation/PROBLEMS @@ -0,0 +1,70 @@ +STRUCTURE + + +VARIABLES + +%% It would be nice to be able to include makefile in a way that + variables are restored. + +@% I definitely need some naming convention for "global" variables. + Since I include potentially unknown makefiles (like library + dependecies) I cannot predict what they do. This is another + argument for variable framing. + + Some ideas: + + - Variables that start and end with '%' are considered global + and system. Subsystems may define such vars if there is + a real need. (Currently defined names should be documented + here. Each subsystem should document names that it defines.) + Subsystem should prefix each such var with its name (e.g. cxx_). + + - Variables that contain '-' are considered 'functions' and not + framed. Generally subsystems should define those. The names + should be chosen carefully in order not to cause name clashes. + (Each subsystem should document names that it defines). + Subsystem should prefix each such function with its name + (e.g. cxx-). + + - Variables that appear in %frame_exclude% are not framed. General + rule is to add only special one-word functions (usually defined + by base subsystem) that are used often and thus having one-word + terse name is very important; for example 'include' or 'import' + + +%% After the inclusion of dependency makefiles I cannot use src_base + becasue it was reset by the included file. So I am forced to use + src_root now which will hurt especially sore when I include from + sub-directories. + + + +DEPENDENCIES : STRUCTURE + +@@ It would be nice to be able to chose dependency type project-wise + and on a by-makefile basis. This could be tricky, however. + +@@ Missing headers assumed generated with some inflexible logic (cur dir). + This can also vary among compilers (which is not something I would worry + too much as long as g++ works). Can I make it more reliable? Maybe capture + this (or essential) dependecies in a Makefile? + +@@ Can I specify dependencies in CORBA projects manually. Do I want to do + that? + +@@ Don't include dependecies when cleaning (configuring?). + + + +MISC + +@@ If I have generated idl files in src directory then build in some other + directory will fail or will use wrong headers. + +%% .NOT_DEFAULT: target in make? + +%@ configuration targets should not be parallel. try make -j 4 Maybe I can + detect that those files do not exist and disable parallelism for this + run. See .MUTEX bug (#3656). + +@@ relative paths and pattern matching does not work very well together diff --git a/documentation/RELEASE b/documentation/RELEASE new file mode 100644 index 0000000..fc216ed --- /dev/null +++ b/documentation/RELEASE @@ -0,0 +1,7 @@ +@@ add header to every file. + +@@ make sure all files conform to the STYLE. + +@@ remove empty directoris (left after disfigure) in examples/ + +@@ update copyright diff --git a/documentation/SHOWCASE b/documentation/SHOWCASE new file mode 100644 index 0000000..1a032f2 --- /dev/null +++ b/documentation/SHOWCASE @@ -0,0 +1,85 @@ +#@@ if a showcase complicated the initial example then it should +# be implemented as a separate example. + +%% build with nested directories from single Makefile + +%% generation of headers/sources from some other source with + automatically generated dependencies (IDL showcase) + +%% two executables in the same dir (though generally not recomended) + +%% selection of PIC by a target (target-specific variables + inheritance) (read the bug report about this feature). + +%% directory Makefiles (need a nice name for them) + +%@ configuration target + + - implemented disfigure only (for now). + + - not complete + + - need to implement configuration of installed dependencies. + +%@ installation target + + - prototype design + + - needs completion + +%@ test target + + - only in libhello + +%% generation of actual dependencies for C++/C + +@@ use of C & C++ compiler from the same Makefile + +@@ another C++/C compiler (Sun CC?) + +@@ cleaning after messy compilers (Sun CC?) + +@@ c subsystem + +@@ Quite mode. all answers defaulted. Error if something is wrong. + +@@ I need some way of programmatically supplying configuration + information (for example for debian package creation). Via + command line variables seems like a reasonable approach. Also + saving configuration seems like a good idea too (i.e. keeping + configuration around) but then I need to make sure there are + no absolute paths. + +%@ Installation process for the build system itself. + + - now installs only build system itself. + +%% What am I going to do with corba? Maybe package it as a separate + incomplete subsystem? + +@% All those "file not found" messages by make are quite nasty. I should + either fix make (preferable) or use -include. + + - using -include for now + +%% variable unsetting: do I still need it? Yes I do. + +@@ installation of examples + +@@ need to clean source code out of @@ + +@! target-specific vpath + +@! Can .INTERMIDIATE help me with .d problem? No! Also it seems + saying something like %.o %.d: %.cxx won't work either? Need + to check this. + +@! Need to run ranlib on certain platforms. Need to detect if I need to. + +@! .cpp-options: if add/remove .cpp-options prereqs the target file does not + get regenerated. Probably need to save list of prereqs and compare with it. + +@! shared library versioning + +@! Need to think on a general idea of state saving (like I do with + .cpp-options). Is there a cleaner way of doing this? diff --git a/documentation/STYLE b/documentation/STYLE new file mode 100644 index 0000000..32799f6 --- /dev/null +++ b/documentation/STYLE @@ -0,0 +1,23 @@ +@@ write "t: p" instead of "t : p" or "t :p" + +@@ write $(call f,a) instead of $(call f, a) or $(call f , a) + +@@ Use '-' to separate words in function names (e.g. foo-bar); + use 'define' to define functions. + +@@ Use '_' to separate words in variable names (e.g. foo_bar); + use := to assign value to a variable. Use '=' if you know + what you are doing. + +@@ Be careful with += in target-specific variables. + +@@ Action explicitly requested by the user (which should correspond + to verbs, e.g. install, clean, configure) should perform without + regards to up-to-dateness. + +@@ Use verbs for .PHONY targets. There is one notable exception:... + +@! maybe declare `__' variable prefix reserved? + +@@ Use directory name as a default phony target in directory makefiles. + (explain why).
\ No newline at end of file diff --git a/documentation/TARGETS b/documentation/TARGETS new file mode 100644 index 0000000..ff5476f --- /dev/null +++ b/documentation/TARGETS @@ -0,0 +1,30 @@ + +# Configuration +# + +configuration +configure : disfigure +disfigure : clean + +# build +# + +build : configuration +clean + + +# test +# +test : build + + +# install +# +install : build +uninstall + + +# help +# + +help diff --git a/documentation/TODO b/documentation/TODO new file mode 100644 index 0000000..4aec2c6 --- /dev/null +++ b/documentation/TODO @@ -0,0 +1,9 @@ +!! Need to change include path in hello example. + +!! And change to #include <> + +!! Need to get rid of those header patterns or implement shortest stem. + +!! finish cxx-d.make + +@@ Add include-dep to examples. diff --git a/documentation/default.css b/documentation/default.css new file mode 100644 index 0000000..7242a94 --- /dev/null +++ b/documentation/default.css @@ -0,0 +1,160 @@ +body { + font-family : sans-serif; + font-weight : normal; + + color : black; + background : white; + + max-width : 42em; + padding : 2em 2em 2em 3em; + margin : 0 auto; +} + +h1, h2, h3, h4, h5, h6 { + font-family : sans-serif; + font-weight : 500; +} + +h1 { font-size : 170%; } +h2 { font-size : 145%; } +h3 { font-size : 125%; } +h4 { font-size : 110%; } +h5 { font-size : 106%; } +h6 { font-size : 100%; } + + +p.indent { + margin-left : 1.5em; +} + + +/* table of content */ +ul.toc li { + padding : .4em 0em 0em 0em; +} + + + +/* list of links */ +ul.menu { + list-style-type : none; +} + +ul.menu li { + padding-top : 0.3em; + padding-bottom : 0.3em; +} + + + +/* @@ I should probably use child selector here */ +/* list with multiline list-elements */ +ul.multiline li { + padding-top : 0.4em; + padding-bottom : 0.4em; +} + +ol.multiline li { + padding-top : 0.4em; + padding-bottom : 0.4em; +} + +dl.multiline dd { + padding-top : 0.4em; + padding-bottom : 0.4em; +} + +/* code */ + +code { + font-size : 114%; + font-family : monospace; +} + + +/* C++ code snippet */ +pre.cxx { + + margin-top : 0em; + margin-bottom : 2em; + + margin-left : 1em; +} + + + +/* make code snippet */ +pre.make { + + margin-top : 0em; + margin-bottom : 2em; + + margin-left : 1em; +} + + + +/* terminal output */ +pre.term { + + margin-top : 0em; + margin-bottom : 2em; + + margin-left : 1em; +} + + +/* Images */ +div.center { + text-align: center; +} + +/* Navigation. */ +#navigation { + margin-top: 1em; + border-bottom: 1px dashed #000000; +} + +#content { + margin-top: 2.5em; +} + + +/* Document info. */ +#docinfo { + margin-top: 4em; + border-top: 1px dashed #000000; + font-size: 70%; +} + +/* distribution terms */ +div.terms { + font-size : 114%; + font-family : monospace; +} + + + +/* Footnote */ + +#footnote { + margin-top: 2em; +} + +#footnote hr { + margin-left: 0; + margin-bottom: 1.5em; + width: 8em; + border-top: 1px solid #000000; + border-right: none; + border-bottom: none; + border-left: none; + +} + +#footnote p { + font-size: .91em; + text-indent: -0.8em; + padding-left: 0.8em; +} + diff --git a/documentation/index.xhtml b/documentation/index.xhtml new file mode 100644 index 0000000..afc655c --- /dev/null +++ b/documentation/index.xhtml @@ -0,0 +1,970 @@ +<?xml version="1.0" encoding="iso-8859-1"?> +<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> +<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en"> + +<!-- + +file : documentation/index.xhtml +author : Boris Kolpackov <boris@codesynthesis.com> +copyright : Copyright (c) 2004-2010 Code Synthesis Tools CC +license : GNU FDL v1.2; http://www.codesynthesis.com/licenses/fdl-1.2.txt + +--> + +<!-- +@@ maybe background code? + +@@ describe all feature that appear in the example. +--> + +<head> + + <title>build/documentation</title> + + <meta name="author" content="Boris Kolpackov"/> + <meta name="copyright" content="© 2004-2010 Code Synthesis Tools CC"/> + <meta name="keywords" content="build,system,make"/> + <meta name="description" content="build/documentation"/> + + <link rel="stylesheet" type="text/css" href="default.css"/> + +</head> + +<body> +<div id="content"> +<ul class="toc"> +<li><a href="#introduction">Introduction</a></li> +<li><a href="#fundamentals">Fundamentals</a></li> +<li><a href="#first_example">First Example</a> + <ul> + <li><a href="#invocation">Invocation</a></li> + <li><a href="#makefiles">Makefiles</a></li> + </ul> +</li> +<li><a href="#inter_project_dependencies">Inter-Project Dependencies</a></li> +<li><a href="#administrivia">Administrivia</a> + <ul> + <li><a href="#license">License</a></li> + <li><a href="#bootstrapping">Bootstrapping</a></li> + <li><a href="#versioning">Versioning</a></li> + </ul> +</li> +</ul> + + +<h1><a name="introduction">Introduction</a></h1> + +<p>I hear you saying: "Yeah, yeah, another marvelous make +replacement with built-in support for various compilers, automatic +dependency scanning, parallel and distributed builds, and XML instead of +makefiles!" On the contrary, <em>build</em> is a software build system +that is implemented on top of GNU make. It defines extensible framework for +translators, delegates most of its tasks to existing tools, and uses GNU +make syntax for makefiles. <em>Build</em> was designed with the following +tasks in mind:</p> + +<ul class="multiline"> + <li>configuration</li> + <li>building</li> + <li>testing</li> + <li>installation</li> +</ul> + +<p>As distribution of software in source code is being replaced by +precompiled package distributions, greater emphasis was placed on +development-time conveniences. Some of the features of <em>build</em> +include:</p> + +<ul class="multiline"> + <li>position-independent makefiles</li> + + <li>non-recursive multi-makefile include-based structure</li> + + <li>leaf makefiles are full-fledged GNU makefiles, not just + variable definitions</li> + + <li>complete dependency graph</li> + + <li>inter-project dependency tracking</li> +</ul> + +<p>To understand leaf makefiles in this manual you will need basic +knowledge of how <code>make</code> works. However, inside, <em>build</em> +uses some of the more advanced features of GNU make including</p> + +<ul class="multiline"> +<li>order-only prerequisites</li> +<li>pattern and target-specific variables</li> +<li><code>$(call )</code> and <code>$(eval )</code></li> +<li>different flavors of <code>include</code> directive</li> +</ul> + +<p>If you find usage of some of the <code>make</code> techniques obscure +in this text you can always consult with the +<a href="http://www.gnu.org/software/make/manual/make.html">GNU make +manual</a>.</p> + + +<h1><a name="fundamentals">Fundamentals</a></h1> + +<p><em>Build</em> defines a framework in terms of which user makefiles +are written. Below is the list of fundamental concepts.</p> + +<dl class="multiline"> +<dt>Project</dt> +<dd>is a separately distributable collection of source files. A more +intuitive way of defining a project would be to say it's what you +normally assign a version number to (e.g., <code>libhello-0.0.1</code>) +and package as a tar ball (e.g., <code>libhello-0.0.1.tar.gz</code>). +A reasonably complex project usually has a hierarchy of sub-directories +under its root directory.</dd> + +<dt>Component</dt> +<dd>is part of a project for which you would normally write a +makefile. For example our <code>libhello</code> could consist of +two components: the library itself and a test driver.</dd> + +<dt>Source root</dt> +<dd>is a root directory of a project. For example, if we unpack our +<code>libhello-0.0.1.tar.gz</code> to <code>/tmp</code> and end up with +a directory <code>/tmp/libhello-0.0.1</code> then that would be this +project's <em>source root</em>.</dd> + +<dt>Source base</dt> +<dd>is a directory of a component in a project. Continuing our example, +if our <code>libhello</code> project had a subdirectory <code>test</code> +then the <em>source base</em> of the <code>test</code> component would be +<code>/tmp/libhello-0.0.1/test</code>. By definition, any <em>source base</em> +is a sub-directory of a <em>source root</em> for any particular project.</dd> + +<dt>Out root</dt> +<dd>is a root directory of a project's build (or output) hierarchy. This +directory signifies where generated files for the project will be placed. +For example, if we decide to build <code>libhello</code> in +<code>/tmp/libhello-i686-pc-linux-gnu</code> then that would be one of the +possible <em>out roots</em>.</dd> + +<dt>Out base</dt> +<dd>is a build (or output) directory of a component in a project. +If we continue our example, the <em>out base</em> for the <code>test</code> +component would be <code>/tmp/libhello-i686-pc-linux-gnu/test</code>.</dd> +</dl> + +<p>The <em>build</em> runtime defines four <code>make</code> variables that +correspond to the last four definitions:</p> + +<pre class="make"> +src_root +src_base +out_root +out_base +</pre> + +<p>Below is an example of how you could use some of them.</p> + +<pre class="make"> +driver := $(out_base)/driver + +$(driver): $(out_base)/driver.o $(out_root)/libhello/libhello.so +</pre> + +<p>Additionally, the <em>build</em> framework defines three more +variables:</p> + +<pre class="make"> +bld_root +scf_root := $(src_root)/build +dcf_root := $(out_root)/build +</pre> + +<p><code>bld_root</code> is a root directory of the <em>build</em> runtime. +Normally you would use it to include one of the <em>build</em>'s files.</p> + +<p><code>scf_root</code> stands for static configuration root and +points to a directory where project's static configuration is kept. +<code>dcf_root</code> stands for dynamic configuration root and +points to a directory where project's dynamic configuration is kept. +We will talk more about those two variables later.</p> + +<p>Also note that having <code>src_root</code> the same as +<code>out_root</code> is perfectly valid and indicates that we +are building in a source directory.</p> + +<h1><a name="first_example">First Example</a></h1> + +<p>Now we are ready to examine our first simple example. We +will skip one-file C-based "hello world", however, because it +is not very practical and there is not much room for improvement. +Rather we will start from a <code>libhello</code> library, a test +driver for it and a <code>hello</code> program that uses the library. +To make our example even more realistic the <code>libhello</code> +library and the <code>hello</code> program are two separate projects. +And, did I mention, they are written in C++. See +<code>examples/cxx/hello</code>.</p> + +<h2><a name="invocation">Invocation</a></h2> + +<p>Let's first get some user experience without looking into makefiles. +Suppose we unpacked <em>build</em> source into <code>/tmp/build-0.1.12</code>. +First let's try to build <code>libhello</code>:</p> + +<pre class="term"> +$ cd /tmp/build-0.1.12/examples/cxx/hello/libhello +$ make + + +configuring 'libhello' + + + +Please select the C++ compiler you would like to use: + +(1) GNU C++ (g++) +(2) Intel C++ (icc) + +[1]: 1 + +Would you like the C++ compiler to optimize generated code? + +[y]: y + +Would you like the C++ compiler to generate debug information? + +[y]: y + + +configuring 'libhello' + + + +Please select the default library type: + +(1) archive +(2) shared object + +[2]: 2 + + +configuring 'libhello' + + + +Please enter the g++ binary you would like to use, for example 'g++-3.4', +'/usr/local/bin/g++' or 'distcc g++'. You can use path auto-completion. + +[g++]: g++ + +Please select the optimization level you would like to use: + +(1) -O1 [Tries to reduce code size and execution time, without + performing any optimizations that take a great deal of + compilation time.] +(2) -O2 [Performs nearly all supported optimizations that do not + involve a space-speed tradeoff.] +(3) -O3 [Optimize even more.] +(4) -Os [Optimize for size.] + +[2]: 2 +c++ /tmp/build-0.1.12/examples/cxx/hello/libhello/libhello/hello.cxx +ld /tmp/build-0.1.12/examples/cxx/hello/libhello/libhello/hello.l +c++ /tmp/build-0.1.12/examples/cxx/hello/libhello/test/driver.cxx +ld /tmp/build-0.1.12/examples/cxx/hello/libhello/test/driver +</pre> + +<p>Here we were presented with a bunch of configuration questions. +If you have <code>g++</code> in your default path you can just keep +hitting enter to select defaults. If you would like to see real commands +that are being executed (useful when something goes wrong) you can +say <code>make verbose=1</code>.</p> + +<p>From the messages above we can deduce that we have built the +<code>libhello</code> library (<code>hello.l</code>) and the test driver +for it (<code>test/driver</code>). So far so good. Now let's try to build +the <code>hello</code> program:</p> + +<pre class="term"> +$ cd /tmp/build-0.1.12/examples/cxx/hello/hello +$ make +</pre> + +<p>Again you will be asked a bunch of questions you have already seen, +except these two:</p> + +<pre class="term"> +Configuring external dependency on 'libhello' for 'hello driver'. + + +Would you like to configure dependency on the installed +version as opposed to the development build? + +[y]: n + +Please enter the out_root for 'libhello'. + +[]: ../libhello + +Please enter the src_root for 'libhello'. + +[]: ../libhello +</pre> + +<p>The <code>hello</code> program depends on <code>libhello</code>. Since +they are distributed as separate projects <code>hello</code> needs to +know where to look for <code>libhello</code>. That's why user intervention +is required. The first question is whether we would like to use an installed +version of <code>libhello</code> as opposed to the not installed build. +Since we haven't installed <code>libhello</code> the answer is +<code>no</code>. The next two questions determine where the +<code>out_root</code> of the build and the <code>src_root</code> of the source +code are. Since we built <code>libhello</code> in its source directory both +become <code>/tmp/build-0.1.12/examples/cxx/hello/libhello</code> or +<code>../libhello</code> if we are in +<code>/tmp/build-0.1.12/examples/cxx/hello/hello</code>. After answering +those questions you will see something like this:</p> + +<pre class="term"> +c++ /tmp/build-0.1.12/examples/cxx/hello/hello/hello.cxx +ld /tmp/build-0.1.12/examples/cxx/hello/hello/hello +</pre> + +<p>And that's it.</p> + +<p>One of the nice features of <em>build</em> is that you can have several +builds in separate directories all from the same source base. Suppose we +would like to build an <code>-O3</code>-optimized statically-linked version +of <code>hello</code> without debug information:</p> + +<pre class="term"> +$ mkdir /tmp/hello-i686-pc-linux-gnu +$ cd /tmp/hello-i686-pc-linux-gnu +$ make -f ../build-0.1.12/examples/cxx/hello/hello/makefile + + +configuring 'hello driver' + + + +Please select the C++ compiler you would like to use: + +(1) GNU C++ (g++) +(2) Intel C++ (icc) + +[1]: 1 + +Would you like the C++ compiler to optimize generated code? + +[y]: y + +Would you like the C++ compiler to generate debug information? + +[y]: n + + +Configuring external dependency on 'libhello' for 'hello driver'. + + + +Would you like to configure dependency on the installed +version as opposed to the development build? + +[y]: n + +Please enter the out_root for 'libhello'. + +[]: /tmp/libhello-i686-pc-linux-gnu + +Please enter the src_root for 'libhello'. + +[]: ../build-0.1.12/examples/cxx/hello/libhello + + +configuring 'hello driver' + + + +Please enter the g++ binary you would like to use, for example 'g++-3.4', +'/usr/local/bin/g++' or 'distcc g++'. You can use path auto-completion. + +[g++]: g++ + +Please select the optimization level you would like to use: + +(1) -O1 [Tries to reduce code size and execution time, without + performing any optimizations that take a great deal of + compilation time.] +(2) -O2 [Performs nearly all supported optimizations that do not + involve a space-speed tradeoff.] +(3) -O3 [Optimize even more.] +(4) -Os [Optimize for size.] + +[2]: 3 + + +configuring 'libhello' + + + +Please select the C++ compiler you would like to use: + +(1) GNU C++ (g++) +(2) Intel C++ (icc) + +[1]: 1 + +Would you like the C++ compiler to optimize generated code? + +[y]: y + +Would you like the C++ compiler to generate debug information? + +[y]: n + + +configuring 'libhello' + + + +Please select the default library type: + +(1) archive +(2) shared object + +[2]: 1 + + +configuring 'libhello' + + + +Please enter the g++ binary you would like to use, for example 'g++-3.4', +'/usr/local/bin/g++' or 'distcc g++'. You can use path auto-completion. + +[g++]: g++ + +Please select the optimization level you would like to use: + +(1) -O1 [Tries to reduce code size and execution time, without + performing any optimizations that take a great deal of + compilation time.] +(2) -O2 [Performs nearly all supported optimizations that do not + involve a space-speed tradeoff.] +(3) -O3 [Optimize even more.] +(4) -Os [Optimize for size.] + +[2]: 3 +c++ /tmp/build-0.1.12/examples/cxx/hello/hello/hello.cxx +c++ /tmp/build-0.1.12/examples/cxx/hello/libhello/libhello/hello.cxx +ar /tmp/libhello-i686-pc-linux-gnu/libhello/hello.l +ld /tmp/hello-i686-pc-linux-gnu/hello +</pre> + +<h2><a name="makefiles">Makefiles</a></h2> + +<p>Now let's take a look at the makefiles. We will start from the +makefile for <code>libhello</code> (<code>hello/libhello/libhello/makefile</code>). +Note, that I removed support for <code>install</code> target for now.</p> + +<pre class="make"> +include $(dir $(lastword $(MAKEFILE_LIST)))../build/bootstrap.make + +cxx_tun := hello.cxx +cxx_obj := $(addprefix $(out_base)/,$(cxx_tun:.cxx=.o)) +cxx_od := $(cxx_obj:.o=.o.d) + +hello.l := $(out_base)/hello.l +hello.l.cpp-options := $(out_base)/hello.l.cpp-options + +clean := $(out_base)/.clean + + +# Build. +# +$(hello.l): $(cxx_obj) + +$(cxx_obj): $(hello.l.cpp-options) + +$(hello.l.cpp-options): value := -I$(src_root) + +$(call -include,$(cxx_od)) + + +# Clean. +# +.PHONY: $(clean) + +$(clean): $(hello.l).clean \ + $(addsuffix .clean,$(cxx_obj)) \ + $(hello.l.cpp-options).clean + + +# Aliases. +# +ifdef %interactive% + +.PHONY: clean + +clean: $(clean) + +endif + + +# How to. +# +$(call include,$(bld_root)/cxx/o-l.make) +$(call include,$(bld_root)/cxx/cxx-o.make) +</pre> + +<p>Let's examine this file line-by-line:</p> + +<pre class="make"> +include $(dir $(lastword $(MAKEFILE_LIST)))../build/bootstrap.make +</pre> + +<p>Every leaf makefile (i.e., one written to build a component) starts from a +line that looks like this. Its sole purpose is to bootstrap the build system. +In our case <code>$(dir $(lastword ...))</code> will expand to something +like</p> + +<pre class="make"> +include .../hello/libhello/libhello/../build/bootstrap.make +</pre> + +<p>Let's take a look at <code>libhello/build/bootstrap.make</code>:</p> + +<pre class="make"> +project_name := libhello +include $(dir $(lastword $(MAKEFILE_LIST))).../build/bootstrap.make +</pre> + +<p>The first line just initializes <code>project_name</code> with the name +of the project. The second line includes the real <code>bootstrap.make</code>. +See <a href="#bootstrap">Bootstrapping</a> section for more information on +various ways of bootstrapping the <em>build</em> runtime.</p> + +<p>What does <code>bootstrap.make</code> do? Besides other things (which are +explained as we encounter them) it sets all those <code>*_root</code> and +<code>*_base</code> variables.</p> + +<p>Let's go back to our <code>libhello/makefile</code>. The first line +should be clear by now so let's move on:</p> + +<pre class="make"> +cxx_tun := hello.cxx +cxx_obj := $(addprefix $(out_base)/,$(cxx_tun:.cxx=.o)) +cxx_od := $(cxx_obj:.o=.o.d) +</pre> + +<p>This should be pretty straightforward: <code>cxx_tun</code> contains +a list of translation units, <code>cxx_obj</code> contains a list of +object files that will be produced from those translation units, and +<code>cxx_od</code> contains a list of automatically generated dependency +files for those translation units. After expansion these variables could +contain the following values (note, in this example <code>out_root</code> +is the same as <code>src_root</code>):</p> + +<pre class="make"> +cxx_tun := hello.cxx +cxx_obj := .../hello/libhello/libhello/hello.o +cxx_od := .../hello/libhello/libhello/hello.o.d +</pre> + +<p>Next chunk:</p> + +<pre class="make"> +hello.l := $(out_base)/hello.l +hello.l.cpp-options := $(out_base)/hello.l.cpp-options + +clean := $(out_base)/.clean +</pre> + +<p><code>hello.l</code> and <code>clean</code> are two variables that +store names of targets. You are probably wondering what the heck +is <code>hello.l</code>? This is a library abstraction the build system +provides to deal (besides other things) with archives/shared objects +uniformly. A user who builds your project can specify what type of +library they want without any additional effort from you. I encourage +you to take a look inside <code>hello.l</code>.</p> + +<p><code>hello.l.cpp-options</code> is a bit trickier. +<code>$(out_base)/hello.l.cpp-options</code> keeps C preprocessor options +that are required to compile library files as well as any piece of code +that uses it. Hopefully, it will become clear once you see the rest of +the makefile.</p> + +<p>Let's move on:</p> + +<pre class="make"> +# Build. +# +$(hello.l): $(cxx_obj) + +$(cxx_obj): $(hello.l.cpp-options) + +$(hello.l.cpp-options): value := -I$(src_root) + +$(call -include,$(cxx_od)) +</pre> + +<p>The first line tells us that <code>hello.l</code> is built from object +files listed in <code>cxx_obj</code>. The second line establishes dependency +of object files on C preprocessor options - in order to build an object file +we will need C++ source file and C preprocessor options - quite logical. The +third line sets target-specific variable <code>value</code> for +<code>hello.l.cpp-options</code>: that's how <code>hello.l.cpp-options</code> +gets its content. You may be wondering why do we need to add this +<code>-I$(src_root)</code>. The first line of <code>hello.cxx +</code> should clear things up:</p> + +<pre class="cxx"> +#include "libhello/hello.hxx" +</pre> + +<p>And finally the fourth line includes auto-generated dependency +information for each object file. You can think of +<code>$(call -include )</code> as being equivalent to <code>-include</code> +directive for now.</p> + + +<p>Next chunk:</p> + +<pre class="make"> +.PHONY: $(clean) + +$(clean): $(hello.l).clean \ + $(addsuffix .clean,$(cxx_obj)) \ + $(hello.l.cpp-options).clean +</pre> + +<p>Let's concentrate on the last line. There we are essentially saying that +cleaning <code>libhello</code> consists of cleaning the library, object +files and C preprocessor options. How does this work? It is done using +pattern rules. Part of the build system that defines how to build say +<code>%.l</code> also defines how to clean after it: <code>%.l.clean</code>. +You may want to look into <code>build/cxx/gnu/o-l.make</code> for details.</p> + +<p>Moving on:</p> + +<pre class="make"> +# Aliases. +# +ifdef %interactive% + +.PHONY: clean + +clean: $(clean) + +endif +</pre> + +<p>In this part we are creating a short alias (<code>clean</code>) +for its long equivalent (<code>$(out_base)/.clean</code>). <code> +%interactive%</code> is a <em>system variable</em> defined by +the framework. It is initialized only if current makefile is +used in interactive mode as opposed to being included.</p> + +<p>And finally:</p> + +<pre class="make"> +# How to. +# +$(call include,$(bld_root)/cxx/o-l.make) +$(call include,$(bld_root)/cxx/cxx-o.make) +</pre> + +<p>In this makefile fragment we are including parts of the build +system that actually know <em>how to build</em>. As you might have +noticed, all the code that we have examined up until now was dealing +with <em>what to build</em>. <code>o-l.make</code> defines a pattern +rule to build libraries from object files. <code>cxx-o.make</code> +defines a pattern rule to build object files from C++ translation units.</p> + +<p>And this concludes our examination of the makefile for +<code>libhello</code>. Next is the test driver( +<code>hello/libhello/test/makefile</code>):</p> + +<pre class="make"> +include $(dir $(lastword $(MAKEFILE_LIST)))../build/bootstrap.make + +cxx_tun := driver.cxx +cxx_obj := $(addprefix $(out_base)/,$(cxx_tun:.cxx=.o)) +cxx_od := $(cxx_obj:.o=.o.d) + +hello.l := $(out_root)/libhello/hello.l +hello.l.cpp-options := $(out_root)/libhello/hello.l.cpp-options + +driver := $(out_base)/driver.e +clean := $(out_base)/.clean +test := $(out_base)/.test + + +# Build. +# +$(driver): $(cxx_obj) $(hello.l) + +$(cxx_obj): $(hello.l.cpp-options) + +$(call -include,$(cxx_od)) + + +# Test. +# +.PHONY: $(test) + +$(test): $(driver) + $< + + +# Clean. +# +.PHONY: $(clean) + +$(clean): $(driver).clean $(addsuffix .clean,$(cxx_obj)) + + +# Aliases. +# +ifdef %interactive% + +.PHONY: clean test + +test: $(test) +clean: $(clean) + +endif + + +# How to. +# +$(call include,$(bld_root)/cxx/o-e.make) +$(call include,$(bld_root)/cxx/cxx-o.make) + + +# Load build information. +# +$(call load,$(src_root)/libhello/makefile) +</pre> + +<p>Do you see anything unknown or strange in this makefile? I hope you don't. +Just to re-iterate, I will remove everything we definitely saw and leave +only what's new:</p> + +<pre class="make"> +hello.l := $(out_root)/libhello/hello.l +hello.l.cpp-options := $(out_root)/libhello/hello.l.cpp-options + + +# Build. +# +$(driver): $(cxx_obj) $(hello.l) + +$(cxx_obj): $(hello.l.cpp-options) + + +# Load build information. +# +$(call load,$(src_root)/libhello/makefile) +</pre> + +<p>All of what's left deals in one way or the other with linking +to <code>libhello</code>. The first two lines define variables that +hold paths to the library and C preprocessor options (since we are in +the same project we know what those paths are relative to +<code>out_root</code>/<code>src_root</code>). The third line declares that +driver consists of object files and should be linked with +<code>libhello</code>. The next line says that we need C preprocessor options +to build object files, just like we did for <code>libhello</code>. And finally +the last line: what does the <code>load</code> function do? The +<code>load</code> function loads rules and dependency information from the +makefile specified. Note that it doesn't make variable definitions from that +makefile available (or, even worse, override ones we set) - only dependencies +and rules. The major benefit of doing this is in having complete dependency +information along with the rules in case something gets out of date. If, for +example, we change something in <code>libhello</code> and then execute +<code>make</code> in <code>test</code>, <code>make</code> will be able to +detect that <code>libhello</code> is out of date and will re-build it before +building the test driver.</p> + +<p>Now let's take a look at the makefile from the <code>hello</code> program +(<code>hello/hello/makefile</code>). Remember that it is a separate project +(I removed support for <code>install</code> target again):</p> + + +<pre class="make"> +include $(dir $(lastword $(MAKEFILE_LIST)))build/bootstrap.make + +cxx_tun := hello.cxx +cxx_obj := $(addprefix $(out_base)/,$(cxx_tun:.cxx=.o)) +cxx_od := $(cxx_obj:.o=.o.d) + +hello.e := $(out_base)/hello.e +clean := $(out_base)/.clean + +# Secure default target. +# +$(hello.e): + + +# Import information about libhello. +# +$(call import,libhello,l: hello.l,cpp-options: hello.l.cpp-options) + + +# Build. +# +$(hello.e): $(cxx_obj) $(hello.l) + +$(cxx_obj): $(hello.l.cpp-options) + +$(call -include,$(cxx_od)) + + +# Clean. +# +.PHONY: $(clean) + +$(clean): $(hello.e).clean $(addsuffix .clean,$(cxx_obj)) + + +# Aliases. +# +ifdef %interactive% + +.PHONY: clean + +clean: $(clean) + +endif + + +# How to. +# +$(call include,$(bld_root)/cxx/o-e.make) +$(call include,$(bld_root)/cxx/cxx-o.make) +</pre> + +<p>Again I will remove all the parts that we are familiar with leaving +only what's new:</p> + +<pre class="make"> +# Secure default target. +# +$(hello.e): + + +# Import information about libhello. +# +$(call import,libhello,l: hello.l,cpp-options: hello.l.cpp-options) +</pre> + +<p>Let's see what's going on here. I will start from the call to +the <code>import</code> function. It is similar to the <code>load</code> +function with a few exceptions. First of all, since we are importing +build information from a separate project we don't know where to look +for its parts; this will require dynamic configuration. Secondly, we +have no way to figure out where <code>hello.l</code> and +<code>hello.l.cpp-options</code> are. Thus we have +<code>`l: hello.l'</code> and <code>`cpp-options: hello.l.cpp-options'</code> +which essentially means "initialize variable <code>hello.l</code> with +the library path and variable <code>hello.l.cpp-options</code> with +the C preprocessor options file path".</p> + +<p>One side effect of the call to <code>import</code> function is the +potential loss of the default target. Thus, the first line.</p> + +<p>The inter-project dependency importing architecture is probably +the most complicated part of the build system. It will be described +in a separate section.</p> + +<p>This concludes our step-by-step examination. It was not trivial +but neither is building real software.</p> + +<h1><a name="inter_project_dependencies">Inter-Project Dependencies</a></h1> + +<p>To be completed.</p> + + +<h1><a name="administrivia">Administrivia</a></h1> + + +<h2><a name="license">License</a></h2> + +<p>The <em>build</em> runtime (makefiles, scripts, etc.) is distributed under +the terms of the <a href="http://www.codesynthesis.com/licenses/gpl-2.txt">GNU General +Public License, version 2</a>. <em>Build</em> documentation is distributed +under the terms of the <a href="http://www.codesynthesis.com/licenses/fdl-1.2.txt">GNU +Free Documentation License, version 1.2</a>.</p> + +<p>In particular, this means that any makefile, script, etc., that +includes, calls, or otherwise links to the <em>build</em> runtime must +be covered by a GPL-compatible license, should you decide to distribute +them.</p> + + +<h2><a name="bootstrapping">Bootstrapping</a></h2> + +<p>There are two ways to use the build system: your project can embed +all necessary files or you can require the <em>build</em> runtime to be +installed. The first approach allows you to make your project self-content, +modulo other external dependencies it might have. The disadvantage of this +approach manifests itself when your project participates in a build with +inter-project dependencies established: your project and the rest of the +build could use different (and potentially incompatible) versions of the +runtime. There is no such problem with the second approach.</p> + +<p>My advice is to go with the installed <em>build</em> unless you have +a compelling reason to do otherwise.</p> + +<p>When you go with the embedded runtime you can copy all necessary files +to your project's <code>build/</code> directory. When you use external +<em>build</em> your <code>build/bootstrap.make</code> might look something +like this:</p> + +<pre class="make"> +project_name := libhello +include build-0.1/bootstrap.make +</pre> + +<p>How will <code>make</code> find <code>build-0.1/bootstrap.make</code>? +There are two ways this can happen: you have the runtime installed (e.g., +into <code>/usr/local/include</code>) where <code>make</code> will look +for it by default or you can tell <code>make</code> where to look using +<code>-I</code> option in the command line or by setting +<code>MAKEFLAGS</code> environment variable.</p> + +<h2><a name="versioning">Versioning</a></h2> + +<p><em>Build</em> uses a three-digit versioning scheme: <code>X.Y.Z</code>. +<code>X</code> is a generation number; it is incremented when a completely +new design is implemented. <code>Y</code> is an interface version; two +<em>build</em> runtimes with different <code>Y</code> have incompatible +interfaces even though the ideology is the same (if ideology changes +<code>X</code> will most likely be incremented). Additionally, odd +<code>Y</code> indicates that it's a development release (similar to +the linux kernel). Finally, <code>Z</code> signifies a release number. +Releases with the same <code>X.Y</code> have the same interface.</p> + +<p>To allow co-existence of several versions of <em>build</em> on the +same system, the <code>X.Y</code> pair is made part of the path (e.g., +<code>/usr/include/build-0.1</code>) thus when you bootstrap the runtime +(in a project-specific <code>bootstrap.make</code>) you specify interface +version:</p> + +<pre class="make"> +include build-0.1/bootstrap.make +</pre> +</div> + + +<div id="docinfo"> +<p>Copyright © 2004-2010 <a href="http://www.codesynthesis.com">Code Synthesis Tools CC</a>.</p> + +<div class="terms"> +Permission is granted to copy, distribute and/or modify this document under +the terms of the <a href="http://www.codesynthesis.com/licenses/fdl-1.2.txt">GNU Free +Documentation License, version 1.2</a>; with no Invariant Sections, no +Front-Cover Texts and no Back-Cover Texts. +</div> +</div> + +</body> +</html> diff --git a/examples/cxx/hello/hello/build/bootstrap.make b/examples/cxx/hello/hello/build/bootstrap.make new file mode 100644 index 0000000..ad397b9 --- /dev/null +++ b/examples/cxx/hello/hello/build/bootstrap.make @@ -0,0 +1,8 @@ +# file : examples/cxx/hello/hello/build/bootstrap.make +# author : Boris Kolpackov <boris@codesynthesis.com> +# copyright : Copyright (c) 2004-2010 Code Synthesis Tools CC +# license : GNU GPL v2; see accompanying LICENSE file + +project_name := hello driver + +include $(dir $(lastword $(MAKEFILE_LIST)))../../../../../build/bootstrap.make diff --git a/examples/cxx/hello/hello/build/import/libhello b/examples/cxx/hello/hello/build/import/libhello new file mode 120000 index 0000000..1943500 --- /dev/null +++ b/examples/cxx/hello/hello/build/import/libhello @@ -0,0 +1 @@ +../../../libhello/build/import/libhello
\ No newline at end of file diff --git a/examples/cxx/hello/hello/hello.cxx b/examples/cxx/hello/hello/hello.cxx new file mode 100644 index 0000000..1ec9d31 --- /dev/null +++ b/examples/cxx/hello/hello/hello.cxx @@ -0,0 +1,8 @@ +#include "libhello/hello.hxx" + +int +main () +{ + hello h; + h.say ("Hello, world!"); +} diff --git a/examples/cxx/hello/hello/makefile b/examples/cxx/hello/hello/makefile new file mode 100644 index 0000000..3fc4826 --- /dev/null +++ b/examples/cxx/hello/hello/makefile @@ -0,0 +1,71 @@ +# file : examples/cxx/hello/hello/makefile +# author : Boris Kolpackov <boris@codesynthesis.com> +# copyright : Copyright (c) 2004-2010 Code Synthesis Tools CC +# license : GNU GPL v2; see accompanying LICENSE file + +include $(dir $(lastword $(MAKEFILE_LIST)))build/bootstrap.make + +cxx_tun := hello.cxx +cxx_obj := $(addprefix $(out_base)/,$(cxx_tun:.cxx=.o)) +cxx_od := $(cxx_obj:.o=.o.d) + +hello := $(out_base)/hello +clean := $(out_base)/.clean +install := $(out_base)/.install + + +# Secure default target. +# +#$(hello): + + +# Import information about libhello. +# +$(call import,\ + $(scf_root)/import/libhello/stub.make,\ + l: hello.l,cpp-options: hello.l.cpp-options) + + +# Build. +# +$(hello): $(cxx_obj) $(hello.l) + +$(cxx_obj) $(cxx_od): $(hello.l.cpp-options) + +$(call -include,$(cxx_od)) + + +# Clean. +# +.PHONY: $(clean) + +$(clean): $(hello).o.clean \ + $(addsuffix .cxx.clean,$(cxx_obj)) \ + $(addsuffix .cxx.clean,$(cxx_od)) + + +# Install. +# +.PHONY: $(install) + +$(install): $(hello) + $(call install-exec,$<,$(install_bin_dir)/hello) + +# Aliases. +# +ifdef %interactive% + +.PHONY: clean install + +clean: $(clean) +install: $(install) + +endif + + +# How to. +# +$(call include,$(bld_root)/cxx/o-e.make) +$(call include,$(bld_root)/cxx/cxx-o.make) +$(call include,$(bld_root)/cxx/cxx-d.make) +$(call include,$(bld_root)/install.make) diff --git a/examples/cxx/hello/libhello/build/bootstrap.make b/examples/cxx/hello/libhello/build/bootstrap.make new file mode 100644 index 0000000..400439c --- /dev/null +++ b/examples/cxx/hello/libhello/build/bootstrap.make @@ -0,0 +1,8 @@ +# file : examples/cxx/hello/libhello/build/bootstrap.make +# author : Boris Kolpackov <boris@codesynthesis.com> +# copyright : Copyright (c) 2004-2010 Code Synthesis Tools CC +# license : GNU GPL v2; see accompanying LICENSE file + +project_name := libhello + +include $(dir $(lastword $(MAKEFILE_LIST)))../../../../../build/bootstrap.make diff --git a/examples/cxx/hello/libhello/build/export/libhello/stub.make b/examples/cxx/hello/libhello/build/export/libhello/stub.make new file mode 100644 index 0000000..1184136 --- /dev/null +++ b/examples/cxx/hello/libhello/build/export/libhello/stub.make @@ -0,0 +1,10 @@ +# file : examples/cxx/hello/libhello/build/export/libhello/stub.make +# author : Boris Kolpackov <boris@codesynthesis.com> +# copyright : Copyright (c) 2004-2010 Code Synthesis Tools CC +# license : GNU GPL v2; see accompanying LICENSE file + +$(call include-once,$(src_root)/libhello/makefile) + +$(call export,\ + l: $(out_root)/libhello/hello.l,\ + cpp-options: $(out_root)/libhello/hello.l.cpp-options) diff --git a/examples/cxx/hello/libhello/build/import/libhello/configuration-rules.make b/examples/cxx/hello/libhello/build/import/libhello/configuration-rules.make new file mode 100644 index 0000000..df8dfda --- /dev/null +++ b/examples/cxx/hello/libhello/build/import/libhello/configuration-rules.make @@ -0,0 +1,15 @@ +# file : examples/cxx/hello/libhello/build/import/libhello/configuration-rules.make +# author : Boris Kolpackov <boris@codesynthesis.com> +# copyright : Copyright (c) 2004-2010 Code Synthesis Tools CC +# license : GNU GPL v2; see accompanying LICENSE file + +$(dcf_root)/import/libhello/configuration-dynamic.make: | $(dcf_root)/import/libhello/. + $(call message,,$(scf_root)/import/libhello/configure $@) + +ifndef %foreign% + +disfigure:: + $(call message,rm $(dcf_root)/import/libhello/configuration-dynamic.make,\ +rm -f $(dcf_root)/import/libhello/configuration-dynamic.make) + +endif diff --git a/examples/cxx/hello/libhello/build/import/libhello/configure b/examples/cxx/hello/libhello/build/import/libhello/configure new file mode 100755 index 0000000..055c17e --- /dev/null +++ b/examples/cxx/hello/libhello/build/import/libhello/configure @@ -0,0 +1,54 @@ +#! /usr/bin/env bash + +# file : examples/cxx/hello/libhello/build/import/libhello/configure +# author : Boris Kolpackov <boris@codesynthesis.com> +# copyright : Copyright (c) 2004-2010 Code Synthesis Tools CC +# license : GNU GPL v2; see accompanying LICENSE file + + +# $1 - out file +# +# bld_root - build root +# project_name - project name +# + +source $bld_root/dialog.bash + +$echo +$echo "Configuring external dependency on 'libhello' for '$project_name'." +$echo + +$echo +$echo "Would you like to configure dependency on the installed" +$echo "version of 'libhello' as opposed to the development build?" +$echo + +installed=`read_y_n y` + + +if [ "$installed" = "n" ]; then + + +$echo +$echo "Please enter the src_root for 'libhello'." +$echo + +src_root=`read_path --directory --exist` + +$echo +$echo "Please enter the out_root for 'libhello'." +$echo + +out_root=`read_path --directory $src_root` + +fi + +echo libhello_installed := $installed >$1 + +if [ "$installed" == "n" ]; then + +echo src_root := $src_root >>$1 +echo scf_root := \$\(src_root\)/build >>$1 +echo out_root := $out_root >>$1 + +fi diff --git a/examples/cxx/hello/libhello/build/import/libhello/stub.make b/examples/cxx/hello/libhello/build/import/libhello/stub.make new file mode 100644 index 0000000..9966a54 --- /dev/null +++ b/examples/cxx/hello/libhello/build/import/libhello/stub.make @@ -0,0 +1,30 @@ +# file : examples/cxx/hello/libhello/build/import/libhello/stub.make +# author : Boris Kolpackov <boris@codesynthesis.com> +# copyright : Copyright (c) 2004-2010 Code Synthesis Tools CC +# license : GNU GPL v2; see accompanying LICENSE file + +$(call include-once,$(scf_root)/import/libhello/configuration-rules.make,$(dcf_root)) + +libhello_installed := + +$(call -include,$(dcf_root)/import/libhello/configuration-dynamic.make) + +ifdef libhello_installed + +ifeq ($(libhello_installed),y) + +$(call export,l: -lhello,cpp-options:) + +else + +# Include export stub. +# +$(call include,$(scf_root)/export/libhello/stub.make) + +endif + +else + +.NOTPARALLEL: + +endif diff --git a/examples/cxx/hello/libhello/libhello/hello.cxx b/examples/cxx/hello/libhello/libhello/hello.cxx new file mode 100644 index 0000000..4c2f721 --- /dev/null +++ b/examples/cxx/hello/libhello/libhello/hello.cxx @@ -0,0 +1,9 @@ +#include "libhello/hello.hxx" + +#include <iostream> + +void hello:: +say (char const* phrase) +{ + std::cerr << phrase << std::endl; +} diff --git a/examples/cxx/hello/libhello/libhello/hello.hxx b/examples/cxx/hello/libhello/libhello/hello.hxx new file mode 100644 index 0000000..ecb9e84 --- /dev/null +++ b/examples/cxx/hello/libhello/libhello/hello.hxx @@ -0,0 +1,6 @@ +class hello +{ +public: + void + say (char const* phrase); +}; diff --git a/examples/cxx/hello/libhello/libhello/makefile b/examples/cxx/hello/libhello/libhello/makefile new file mode 100644 index 0000000..3b5752a --- /dev/null +++ b/examples/cxx/hello/libhello/libhello/makefile @@ -0,0 +1,65 @@ +# file : examples/cxx/hello/libhello/libhello/makefile +# author : Boris Kolpackov <boris@codesynthesis.com> +# copyright : Copyright (c) 2004-2010 Code Synthesis Tools CC +# license : GNU GPL v2; see accompanying LICENSE file + +include $(dir $(lastword $(MAKEFILE_LIST)))../build/bootstrap.make + +cxx_tun := hello.cxx +cxx_obj := $(addprefix $(out_base)/,$(cxx_tun:.cxx=.o)) +cxx_od := $(cxx_obj:.o=.o.d) + +hello.l := $(out_base)/hello.l +hello.l.cpp-options := $(out_base)/hello.l.cpp-options + +install := $(out_base)/.install +clean := $(out_base)/.clean + + +# Build. +# +$(hello.l): $(cxx_obj) + +$(cxx_obj) $(cxx_od): $(hello.l.cpp-options) + +$(hello.l.cpp-options): value := -I$(src_root) + +$(call -include,$(cxx_od)) + + +# Clean. +# +.PHONY: $(clean) + +$(clean): $(hello.l).o.clean \ + $(addsuffix .cxx.clean,$(cxx_obj)) \ + $(addsuffix .cxx.clean,$(cxx_od)) \ + $(hello.l.cpp-options).clean + + +# Install. +# +.PHONY: $(install) + +$(install): $(hello.l) + $(call install-lib,$<,$(install_lib_dir)/$(ld_lib_prefix)hello$(ld_lib_suffix)) + $(call install-dir,$(src_base),$(install_inc_dir)/libhello,-name '*.hxx') + +# Aliases. +# +ifdef %interactive% + +.PHONY: clean install + +clean: $(clean) +install: $(install) + +endif + + +# How to. +# +$(call include,$(bld_root)/cxx/o-l.make) +$(call include,$(bld_root)/cxx/cxx-o.make) +$(call include,$(bld_root)/cxx/cxx-d.make) +$(call include,$(bld_root)/install.make) diff --git a/examples/cxx/hello/libhello/makefile b/examples/cxx/hello/libhello/makefile new file mode 100644 index 0000000..ed5ceff --- /dev/null +++ b/examples/cxx/hello/libhello/makefile @@ -0,0 +1,39 @@ +# file : examples/cxx/hello/libhello/makefile +# author : Boris Kolpackov <boris@codesynthesis.com> +# copyright : Copyright (c) 2004-2010 Code Synthesis Tools CC +# license : GNU GPL v2; see accompanying LICENSE file + +include $(dir $(lastword $(MAKEFILE_LIST)))build/bootstrap.make + +default := $(out_base)/ +install := $(out_base)/.install +clean := $(out_base)/.clean +test := $(out_base)/.test + +.PHONY: $(default) $(install) $(test) $(clean) + +$(default): $(out_base)/libhello/hello.l $(out_base)/test/driver + +$(install): $(out_base)/libhello/.install + +$(clean): $(out_base)/libhello/.clean $(out_base)/test/.clean + +$(test): $(out_base)/test/.test + + +# Aliases. +# +ifdef %interactive% + +.PHONY: install test clean + +install: $(install) +clean: $(clean) +test: $(test) + +endif + +# Import build rules. +# +$(call import,$(src_base)/libhello/makefile) +$(call import,$(src_base)/test/makefile) diff --git a/examples/cxx/hello/libhello/test/driver.cxx b/examples/cxx/hello/libhello/test/driver.cxx new file mode 100644 index 0000000..ff25abd --- /dev/null +++ b/examples/cxx/hello/libhello/test/driver.cxx @@ -0,0 +1,8 @@ +#include "libhello/hello.hxx" + +int +main () +{ + hello h; + h.say ("Hey, hey, hey!"); +} diff --git a/examples/cxx/hello/libhello/test/makefile b/examples/cxx/hello/libhello/test/makefile new file mode 100644 index 0000000..d4fb4da --- /dev/null +++ b/examples/cxx/hello/libhello/test/makefile @@ -0,0 +1,67 @@ +# file : examples/cxx/hello/libhello/test/makefile +# author : Boris Kolpackov <boris@codesynthesis.com> +# copyright : Copyright (c) 2004-2010 Code Synthesis Tools CC +# license : GNU GPL v2; see accompanying LICENSE file + +include $(dir $(lastword $(MAKEFILE_LIST)))../build/bootstrap.make + +cxx_tun := driver.cxx +cxx_obj := $(addprefix $(out_base)/,$(cxx_tun:.cxx=.o)) +cxx_od := $(cxx_obj:.o=.o.d) + +hello.l := $(out_root)/libhello/hello.l +hello.l.cpp-options := $(out_root)/libhello/hello.l.cpp-options + +driver := $(out_base)/driver +clean := $(out_base)/.clean +test := $(out_base)/.test + + +# Build. +# +$(driver): $(cxx_obj) $(hello.l) + +$(cxx_obj) $(cxx_od): $(hello.l.cpp-options) + +$(call -include,$(cxx_od)) + + +# Test. +# +.PHONY: $(test) + +$(test): $(driver) + $< + + +# Clean. +# +.PHONY: $(clean) + +$(clean): $(driver).o.clean \ + $(addsuffix .cxx.clean,$(cxx_obj)) \ + $(addsuffix .cxx.clean,$(cxx_od)) + + +# Aliases. +# +ifdef %interactive% + +.PHONY: clean test + +test: $(test) +clean: $(clean) + +endif + + +# How to. +# +$(call include,$(bld_root)/cxx/o-e.make) +$(call include,$(bld_root)/cxx/cxx-o.make) +$(call include,$(bld_root)/cxx/cxx-d.make) + + +# Import build rules. +# +$(call import,$(src_root)/libhello/makefile) diff --git a/examples/cxx/multidir/bar/bar.cxx b/examples/cxx/multidir/bar/bar.cxx new file mode 100644 index 0000000..31781e8 --- /dev/null +++ b/examples/cxx/multidir/bar/bar.cxx @@ -0,0 +1,4 @@ +void +bar () +{ +} diff --git a/examples/cxx/multidir/build/bootstrap.make b/examples/cxx/multidir/build/bootstrap.make new file mode 100644 index 0000000..ac19a30 --- /dev/null +++ b/examples/cxx/multidir/build/bootstrap.make @@ -0,0 +1,8 @@ +# file : examples/cxx/multidir/build/bootstrap.make +# author : Boris Kolpackov <boris@codesynthesis.com> +# copyright : Copyright (c) 2004-2010 Code Synthesis Tools CC +# license : GNU GPL v2; see accompanying LICENSE file + +project_name := multidir + +include $(dir $(lastword $(MAKEFILE_LIST)))../../../../build/bootstrap.make diff --git a/examples/cxx/multidir/driver.cxx b/examples/cxx/multidir/driver.cxx new file mode 100644 index 0000000..70b4146 --- /dev/null +++ b/examples/cxx/multidir/driver.cxx @@ -0,0 +1,4 @@ +int +main () +{ +} diff --git a/examples/cxx/multidir/foo/foo.cxx b/examples/cxx/multidir/foo/foo.cxx new file mode 100644 index 0000000..5b5ccbf --- /dev/null +++ b/examples/cxx/multidir/foo/foo.cxx @@ -0,0 +1,4 @@ +void +foo () +{ +} diff --git a/examples/cxx/multidir/makefile b/examples/cxx/multidir/makefile new file mode 100644 index 0000000..c368828 --- /dev/null +++ b/examples/cxx/multidir/makefile @@ -0,0 +1,47 @@ +# file : examples/cxx/multidir/makefile +# author : Boris Kolpackov <boris@codesynthesis.com> +# copyright : Copyright (c) 2004-2010 Code Synthesis Tools CC +# license : GNU GPL v2; see accompanying LICENSE file + +include $(dir $(lastword $(MAKEFILE_LIST)))build/bootstrap.make + +cxx_tun := driver.cxx foo/foo.cxx bar/bar.cxx +cxx_obj := $(addprefix $(out_base)/,$(cxx_tun:.cxx=.o)) +cxx_od := $(cxx_obj:.o=.o.d) + +driver := $(out_base)/driver +clean := $(out_base)/.clean + + +# Build. +# +$(driver): $(cxx_obj) + +$(call -include,$(cxx_od)) + + +# Clean +# +.PHONY: $(clean) + +$(clean): $(driver).o.clean \ + $(addsuffix .cxx.clean,$(cxx_obj)) \ + $(addsuffix .cxx.clean,$(cxx_od)) + + +# Aliases. +# +ifdef %interactive% + +.PHONY: clean + +clean: $(clean) + +endif + + +# How to. +# +$(call include,$(bld_root)/cxx/o-e.make) +$(call include,$(bld_root)/cxx/cxx-o.make) +$(call include,$(bld_root)/cxx/cxx-d.make) diff --git a/examples/m4/libhello/build/bootstrap.make b/examples/m4/libhello/build/bootstrap.make new file mode 100644 index 0000000..7288d7b --- /dev/null +++ b/examples/m4/libhello/build/bootstrap.make @@ -0,0 +1,8 @@ +# file : examples/m4/hello/libhello/build/bootstrap.make +# author : Boris Kolpackov <boris@codesynthesis.com> +# copyright : Copyright (c) 2004-2010 Code Synthesis Tools CC +# license : GNU GPL v2; see accompanying LICENSE file + +project_name := libhello + +include $(dir $(lastword $(MAKEFILE_LIST)))../../../../build/bootstrap.make diff --git a/examples/m4/libhello/hello/hello.cxx b/examples/m4/libhello/hello/hello.cxx new file mode 100644 index 0000000..049e9ce --- /dev/null +++ b/examples/m4/libhello/hello/hello.cxx @@ -0,0 +1,9 @@ +#include <hello/hello.hxx> + +#include <iostream> + +void hello:: +say (char const* phrase) +{ + std::cerr << phrase << std::endl; +} diff --git a/examples/m4/libhello/hello/hello.hxx.m4 b/examples/m4/libhello/hello/hello.hxx.m4 new file mode 100644 index 0000000..1446096 --- /dev/null +++ b/examples/m4/libhello/hello/hello.hxx.m4 @@ -0,0 +1,10 @@ +dnl +dnl There aren't any macro expansions; it's just an example. +dnl + +class hello +{ +public: + void + say (char const* phrase); +}; diff --git a/examples/m4/libhello/hello/makefile b/examples/m4/libhello/hello/makefile new file mode 100644 index 0000000..26d98a9 --- /dev/null +++ b/examples/m4/libhello/hello/makefile @@ -0,0 +1,71 @@ +# file : examples/m4/hello/libhello/hello/makefile +# author : Boris Kolpackov <boris@codesynthesis.com> +# copyright : Copyright (c) 2004-2010 Code Synthesis Tools CC +# license : GNU GPL v2; see accompanying LICENSE file + +include $(dir $(lastword $(MAKEFILE_LIST)))../build/bootstrap.make + +cxx_tun := hello.cxx +cxx_obj := $(addprefix $(out_base)/,$(cxx_tun:.cxx=.o)) +cxx_od := $(cxx_obj:.o=.o.d) + +hello.l := $(out_base)/hello.l +hello.l.cpp-options := $(out_base)/hello.l.cpp-options + +install := $(out_base)/.install +clean := $(out_base)/.clean + + +# Build. +# +$(hello.l): $(cxx_obj) + +$(cxx_obj) $(cxx_od): $(hello.l.cpp-options) + +#@@ not necessary +#$(out_base)/hello.hxx: $(src_base)/hello.hxx.m4 + +$(hello.l.cpp-options): prefix := hello/ $(out_root)/ +$(hello.l.cpp-options): value := -I$(src_root) -I$(out_root) + +$(call -include,$(cxx_od)) + + +# Clean. +# +.PHONY: $(clean) + +$(clean): $(hello.l).o.clean \ + $(addsuffix .cxx.clean,$(cxx_obj)) \ + $(addsuffix .cxx.clean,$(cxx_od)) \ + $(out_base)/hello.hxx.m4.clean \ + $(hello.l.cpp-options).clean + + +# !! broken: need to install hello.hxx from out_root Install. +# +.PHONY: $(install) + +$(install): $(hello.l) + $(call install-lib,$<,$(install_lib_dir)/$(ld_lib_prefix)hello$(ld_lib_suffix)) + $(call install-dir,$(src_base),$(install_inc_dir)/hello,-name '*.hxx') + +# Aliases. +# +ifdef %interactive% + +.PHONY: clean install + +clean: $(clean) +install: $(install) + +endif + + +# How to. +# +$(call include,$(bld_root)/cxx/o-l.make) +$(call include,$(bld_root)/cxx/cxx-o.make) +$(call include,$(bld_root)/cxx/cxx-d.make) +$(call include,$(bld_root)/m4/m4.make) +$(call include,$(bld_root)/install.make) diff --git a/examples/m4/libhello/makefile b/examples/m4/libhello/makefile new file mode 100644 index 0000000..fcb5bb2 --- /dev/null +++ b/examples/m4/libhello/makefile @@ -0,0 +1,39 @@ +# file : examples/cxx/hello/libhello/makefile +# author : Boris Kolpackov <boris@codesynthesis.com> +# copyright : Copyright (c) 2004-2010 Code Synthesis Tools CC +# license : GNU GPL v2; see accompanying LICENSE file + +include $(dir $(lastword $(MAKEFILE_LIST)))build/bootstrap.make + +default := $(out_base)/ +install := $(out_base)/.install +clean := $(out_base)/.clean +test := $(out_base)/.test + +.PHONY: $(default) $(install) $(test) $(clean) + +$(default): $(out_base)/hello/hello.l $(out_base)/test/driver + +$(install): $(out_base)/hello/.install + +$(clean): $(out_base)/hello/.clean $(out_base)/test/.clean + +$(test): $(out_base)/test/.test + + +# Aliases. +# +ifdef %interactive% + +.PHONY: install test clean + +install: $(install) +clean: $(clean) +test: $(test) + +endif + +# Import build rules. +# +$(call import,$(src_base)/hello/makefile) +$(call import,$(src_base)/test/makefile) diff --git a/examples/m4/libhello/test/driver.cxx b/examples/m4/libhello/test/driver.cxx new file mode 100644 index 0000000..1809049 --- /dev/null +++ b/examples/m4/libhello/test/driver.cxx @@ -0,0 +1,10 @@ +#include <hello/hello.hxx> + +#include "driver.hxx" + +int +main () +{ + hello h; + h.say (msg); +} diff --git a/examples/m4/libhello/test/driver.hxx.m4 b/examples/m4/libhello/test/driver.hxx.m4 new file mode 100644 index 0000000..366ea66 --- /dev/null +++ b/examples/m4/libhello/test/driver.hxx.m4 @@ -0,0 +1,5 @@ +dnl +dnl There aren't any macro expansions; it's just an example. +dnl + +char const* const msg = "Hey, hey, hey!"; diff --git a/examples/m4/libhello/test/makefile b/examples/m4/libhello/test/makefile new file mode 100644 index 0000000..7fce1ea --- /dev/null +++ b/examples/m4/libhello/test/makefile @@ -0,0 +1,70 @@ +# file : examples/cxx/hello/libhello/test/makefile +# author : Boris Kolpackov <boris@codesynthesis.com> +# copyright : Copyright (c) 2004-2010 Code Synthesis Tools CC +# license : GNU GPL v2; see accompanying LICENSE file + +include $(dir $(lastword $(MAKEFILE_LIST)))../build/bootstrap.make + +cxx_tun := driver.cxx +cxx_obj := $(addprefix $(out_base)/,$(cxx_tun:.cxx=.o)) +cxx_od := $(cxx_obj:.o=.o.d) + +hello.l := $(out_root)/hello/hello.l +hello.l.cpp-options := $(out_root)/hello/hello.l.cpp-options + +driver := $(out_base)/driver +clean := $(out_base)/.clean +test := $(out_base)/.test + + +# Build. +# +$(driver): $(cxx_obj) $(hello.l) + +$(cxx_obj) $(cxx_od): $(hello.l.cpp-options) +$(cxx_obj) $(cxx_od): cpp_options := -I$(out_base) + +$(call -include,$(cxx_od)) + + +# Test. +# +.PHONY: $(test) + +$(test): $(driver) + $< + + +# Clean. +# +.PHONY: $(clean) + +$(clean): $(driver).o.clean \ + $(addsuffix .cxx.clean,$(cxx_obj)) \ + $(addsuffix .cxx.clean,$(cxx_od)) \ + $(out_base)/driver.hxx.m4.clean + + +# Aliases. +# +ifdef %interactive% + +.PHONY: clean test + +test: $(test) +clean: $(clean) + +endif + + +# How to. +# +$(call include,$(bld_root)/cxx/o-e.make) +$(call include,$(bld_root)/cxx/cxx-o.make) +$(call include,$(bld_root)/cxx/cxx-d.make) +$(call include,$(bld_root)/m4/m4.make) + + +# Import build rules. +# +$(call import,$(src_root)/hello/makefile) diff --git a/makefile b/makefile new file mode 100644 index 0000000..31b89e9 --- /dev/null +++ b/makefile @@ -0,0 +1,37 @@ +# file : makefile +# author : Boris Kolpackov <boris@codesynthesis.com> +# copyright : Copyright (c) 2004-2010 Code Synthesis Tools CC +# license : GNU GPL v2; see accompanying LICENSE file + +include $(dir $(lastword $(MAKEFILE_LIST)))build/bootstrap.make + +# Help. +# +.PHONY: help + +help: + @echo + @echo "Available targets:" + @echo + @echo " help - print this message" + @echo " install [install_prefix=<prefix>] - install build system" + @echo + @echo "You can also build various examples by executing make in " + @echo "corresponding directories." + @echo + + +# Install. +# +.PHONY: install $(out_base)/.install + +install: $(out_base)/.install + +$(out_base)/.install: + $(call install-dir,$(bld_root),$(install_inc_dir)/build-$(shell \ +sed -e 's%\(.*\)\.\(.*\)\.\(.*\)%\1.\2%' <$(src_base)/version)) + + +# How to. +# +$(call include,$(bld_root)/install.make) diff --git a/tests/frame/makefile b/tests/frame/makefile new file mode 100644 index 0000000..a36321f --- /dev/null +++ b/tests/frame/makefile @@ -0,0 +1,41 @@ +# file : build/frame/makefile +# author : Boris Kolpackov <boris@codesynthesis.com> +# copyright : Copyright (c) 2004-2010 Code Synthesis Tools CC +# license : GNU GPL v2; see accompanying LICENSE file + +include $(dir $(lastword $(MAKEFILE_LIST)))../../build/bootstrap.make + +out_dir := foo + +%foo% := baz + +$(warning $(out_dir)) + +# $(warning $(call frame-vars)) + +$(call frame-enter) + +out_dir := foz +src_dir := baz + +new := new var + +$(call frame-enter) + +out_dir := faz + +$(warning $(out_dir)) +$(warning $(new)) + +$(call frame-leave) + +$(warning $(out_dir)) +$(warning $(new)) + +$(call frame-leave) + +$(warning $(out_dir)) +$(warning $(new)) + +.PHONY: all +all:;@: diff --git a/tests/frame/save-restore.make b/tests/frame/save-restore.make new file mode 100644 index 0000000..b81a087 --- /dev/null +++ b/tests/frame/save-restore.make @@ -0,0 +1,49 @@ + +include $(dir $(lastword $(MAKEFILE_LIST)))../../build/frame.make + +define set-recursive +$1 = $2 +endef + +define set-simple +$1 := $2 +endef + +define save +$(eval $(if $(filter simple,$(flavor $1))\ +,$(call set-simple,_$1,$(value $1))\ +,$(call set-recursive,_$1,$(value $1)))) +endef + +define restore +$(eval $(if $(filter simple,$(flavor _$1))\ +,$(call set-simple,$1,$(value _$1))\ +,$(call set-recursive,$1,$(value _$1)))) +endef + +save = $(call frame-save,$1) +restore = $(call frame-restore,$1) + +r = $(r2) + +s := simple + +$(call save,r) +$(call save,s) + +#$(warning _r: $(value _r)) +#$(warning _s: $(value _s)) + +r := foo +s = bar + +$(call restore,r) +$(call restore,s) + +r2 := recursive + +$(warning r: $r) +$(warning s: $s) + +.PHONY: all +all:;@: diff --git a/tests/import/makefile b/tests/import/makefile new file mode 100644 index 0000000..4a9a8f5 --- /dev/null +++ b/tests/import/makefile @@ -0,0 +1,43 @@ +# file : build/import/makefile +# author : Boris Kolpackov <boris@codesynthesis.com> +# copyright : Copyright (c) 2004-2010 Code Synthesis Tools CC +# license : GNU GPL v2; see accompanying LICENSE file + +include $(dir $(lastword $(MAKEFILE_LIST)))../../build/bootstrap.make + +foo := foz + +$(call frame-push,foo bar) + +bar := bar + +foo := foo + +$(call frame-pop) + +# a := $(call frame-vars) + +#$(warning $(filter-out $b,$a)) + +$(warning foo = $(foo)) +$(warning bar = $(bar)) + +exclude := $(call exported-names,default: libhello,clean: libhello_clean) + +$(call import-names,default: libhello,clean: libhello_clean) + +$(warning $(default:)) +$(warning $(clean:)) +$(warning $(exclude)) + +$(call frame-push) + +$(default:) := fofofof + +$(warning $(libhello)) + +$(call frame-pop) + + +.PHONY: h +h:;@: diff --git a/tests/include/included b/tests/include/included new file mode 100644 index 0000000..8bca82f --- /dev/null +++ b/tests/include/included @@ -0,0 +1,6 @@ +# file : build/include/included +# author : Boris Kolpackov <boris@codesynthesis.com> +# copyright : Copyright (c) 2004-2010 Code Synthesis Tools CC +# license : GNU GPL v2; see accompanying LICENSE file + +$(warning included for $(foo)) diff --git a/tests/include/makefile b/tests/include/makefile new file mode 100644 index 0000000..0250228 --- /dev/null +++ b/tests/include/makefile @@ -0,0 +1,25 @@ +# file : build/include/makefile +# author : Boris Kolpackov <boris@codesynthesis.com> +# copyright : Copyright (c) 2004-2010 Code Synthesis Tools CC +# license : GNU GPL v2; see accompanying LICENSE file + +include $(dir $(lastword $(MAKEFILE_LIST)))../../build/bootstrap.make + +foo := one + +$(call include-once,included,$(foo)) +$(call include-once,included,$(foo)) + +foo := two + +$(call include-once,included,$(foo)) +$(call include-once,included,$(foo)) + +foo := one + +$(call include-once,included,$(foo)) + +$(warning $(value %include_once_$(realpath included)%)) + +.PHONY: h +h:;@: @@ -0,0 +1 @@ +0.3.6 |