001: /*
002: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
003: *
004: * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved.
005: *
006: * The contents of this file are subject to the terms of either the GNU
007: * General Public License Version 2 only ("GPL") or the Common
008: * Development and Distribution License("CDDL") (collectively, the
009: * "License"). You may not use this file except in compliance with the
010: * License. You can obtain a copy of the License at
011: * http://www.netbeans.org/cddl-gplv2.html
012: * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
013: * specific language governing permissions and limitations under the
014: * License. When distributing the software, include this License Header
015: * Notice in each file and include the License file at
016: * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this
017: * particular file as subject to the "Classpath" exception as provided
018: * by Sun in the GPL Version 2 section of the License file that
019: * accompanied this code. If applicable, add the following below the
020: * License Header, with the fields enclosed by brackets [] replaced by
021: * your own identifying information:
022: * "Portions Copyrighted [year] [name of copyright owner]"
023: *
024: * Contributor(s):
025: *
026: * The Original Software is NetBeans. The Initial Developer of the Original
027: * Software is Sun Microsystems, Inc. Portions Copyright 1997-2007 Sun
028: * Microsystems, Inc. All Rights Reserved.
029: *
030: * If you wish your version of this file to be governed by only the CDDL
031: * or only the GPL Version 2, indicate your decision by adding
032: * "[Contributor] elects to include this software in this distribution
033: * under the [CDDL or GPL Version 2] license." If you do not indicate a
034: * single choice of license, a recipient has the option to distribute
035: * your version of this file under either the CDDL, the GPL Version 2 or
036: * to extend the choice of license to its licensees as provided above.
037: * However, if you add GPL Version 2 code and therefore, elected the GPL
038: * Version 2 license, then the option applies only if the new code is
039: * made subject to such option by the copyright holder.
040: */
041:
042: package org.netbeans.modules.cnd.makewizard;
043:
044: import java.util.ResourceBundle;
045: import org.openide.util.NbBundle;
046:
047: /** The Standard Libraries flags are stored here */
048: public final class StdLibFlags {
049:
050: public StdLib motif = new StdLib(getString("TB_Motif"), getString(
051: "MNEM_Motif").charAt(0), "-lXm -lXt -lXext -lX11"); // NOI18N
052: public StdLib math = new StdLib(getString("TB_Math"), getString(
053: "MNEM_Math").charAt(0), "-lm"); // NOI18N
054: public StdLib socketnsl = new StdLib(getString("TB_Nsl"),
055: getString("MNEM_Nsl").charAt(0), "-lsocket -lnsl"); // NOI18N
056: public StdLib solthread = new StdLib(getString("TB_SolThreads"),
057: getString("MNEM_SolThreads").charAt(0), "-lthread"); // NOI18N
058: public StdLib posixthread = new StdLib(
059: getString("TB_PosixThreads"),
060: getString("MNEM_PosixThreads").charAt(0), "-lpthread"); // NOI18N
061: public StdLib posix4 = new StdLib(getString("TB_Posix4"),
062: getString("MNEM_Posix4").charAt(0), "-lposix4"); // NOI18N
063: public StdLib i18n = new StdLib(getString("TB_I18n"), getString(
064: "MNEM_I18n").charAt(0), "-lintl"); // NOI18N
065: public StdLib genlib = new StdLib(getString("TB_GenLib"),
066: getString("MNEM_GenLib").charAt(0), "-lm"); // NOI18N
067: public StdLib dynamiclib = new StdLib(getString("TB_DynamicLib"),
068: getString("MNEM_DynamicLib").charAt(0), "-ldl"); // NOI18N
069: public StdLib curses = new StdLib(getString("TB_Curses"),
070: getString("MNEM_Curses").charAt(0), "-lcurses"); // NOI18N
071: public StdLib rwtools = new StdLib(getString("TB_RWTools"),
072: getString("MNEM_RWTools").charAt(0),
073: "-library=rwtools7,iostream"); // NOI18N
074: public StdLib perflib = new StdLib(getString("TB_PerfLib"),
075: getString("MNEM_PerfLib").charAt(0), "-xlic_lib=sunperf"); // NOI18N
076:
077: private StdLib[] solarisStdLibs = { motif, perflib, math,
078: socketnsl, solthread, posixthread, posix4, i18n, genlib,
079: //dynamiclib,
080: curses, rwtools, };
081:
082: private StdLib[] linuxStdLibs = { motif, math, posixthread,
083: dynamiclib, curses, };
084:
085: private StdLib[] macosxStdLibs = { math, posixthread, dynamiclib,
086: curses, };
087:
088: /** Determine the link type */
089: private int linkType;
090: public final static int STATIC_LINK_TYPE = 0;
091: public final static int DYNAMIC_LINK_TYPE = 1;
092:
093: /** Create a new StdLibFlags and initialize */
094: public StdLibFlags() {
095: linkType = DYNAMIC_LINK_TYPE;
096: }
097:
098: /** Construct a StdLibFlags from an existing one */
099: public StdLibFlags(StdLibFlags old) {
100: this .motif = new StdLib(old.motif);
101: this .math = new StdLib(old.math);
102: this .socketnsl = new StdLib(old.socketnsl);
103: this .solthread = new StdLib(old.solthread);
104: this .posixthread = new StdLib(old.posixthread);
105: this .posix4 = new StdLib(old.posix4);
106: this .i18n = new StdLib(old.i18n);
107: this .genlib = new StdLib(old.genlib);
108: this .dynamiclib = new StdLib(old.dynamiclib);
109: this .curses = new StdLib(old.curses);
110: this .rwtools = new StdLib(old.rwtools);
111: this .perflib = new StdLib(old.perflib);
112: }
113:
114: public StdLib[] getSolarisStdLibs() {
115: return solarisStdLibs;
116: }
117:
118: public StdLib[] getLinuxStdLibs() {
119: return linuxStdLibs;
120: }
121:
122: public StdLib[] getMacOSXStdLibs() {
123: return macosxStdLibs;
124: }
125:
126: /** Getter for the boolean Motif library flag */
127: public boolean isMotifLibs() {
128: return motif.isUsed();
129: }
130:
131: /** Setter for the boolean Motif library flag */
132: public void setMotifLibs(boolean motifLibs) {
133: motif.setUsed(motifLibs);
134: }
135:
136: /** Getter for the link type library flag */
137: public int getLinkType() {
138: return linkType;
139: }
140:
141: /** Setter for the boolean link type library flag */
142: public void setLinkType(int linkType) {
143: if (linkType == STATIC_LINK_TYPE
144: || linkType == DYNAMIC_LINK_TYPE) {
145: this .linkType = linkType;
146: }
147: }
148:
149: public String getSysLibFlags(int toolset, int os, boolean is64Bit,
150: TargetData t) {
151: StringBuffer buf = new StringBuffer(1024);
152:
153: if (getLinkType() == StdLibFlags.DYNAMIC_LINK_TYPE) {
154: if (toolset == MakefileData.SUN_TOOLSET_TYPE) {
155: //buf.append("-Bdynamic "); // NOI18N
156: ; // nothing
157: } else {
158: ; // nothing
159: }
160: } else if (getLinkType() == StdLibFlags.STATIC_LINK_TYPE) {
161: if (toolset == MakefileData.SUN_TOOLSET_TYPE) {
162: buf.append("-Bstatic "); // NOI18N
163: } else {
164: buf.append("-static "); // NOI18N
165: }
166: }
167:
168: // X-Designer will supply these libraries another way
169: if (isMotifLibs() && !t.containsXdFiles()) {
170: if (os == MakefileData.SOLARIS_OS_TYPE) {
171: if (is64Bit) {
172: buf.append("-L/usr/openwin/lib/sparcv9 "); // NOI18N
173: buf.append("-L/usr/dt/lib/sparcv9 "); // NOI18N
174: buf.append("-R/usr/openwin/lib/sparcv9 "); // NOI18N
175: buf.append("-R/usr/dt/lib/sparcv9 "); // NOI18N
176: } else {
177: buf.append("-L/usr/openwin/lib -L/usr/dt/lib "); // NOI18N
178: buf.append("-R/usr/openwin/lib -R/usr/dt/lib "); // NOI18N
179: }
180: } else if (os == MakefileData.LINUX_OS_TYPE) {
181: if (is64Bit) {
182: // ???
183: buf.append("-L/usr/X11R6/lib "); // NOI18N
184: } else {
185: buf.append("-L/usr/X11R6/lib "); // NOI18N
186: }
187: } else {
188: ; // FIXUP - error
189: }
190: }
191:
192: StdLib[] stdLibs;
193: if (os == MakefileData.SOLARIS_OS_TYPE) {
194: stdLibs = getSolarisStdLibs();
195: } else if (os == MakefileData.MACOSX_OS_TYPE) {
196: stdLibs = getMacOSXStdLibs();
197: } else {
198: stdLibs = getLinuxStdLibs();
199: }
200:
201: // Unset certain libs if x-designer
202: if (t.containsXdFiles()) {
203: motif.setUsed(false);
204: socketnsl.setUsed(false);
205: genlib.setUsed(false);
206: }
207:
208: for (int i = 0; i < stdLibs.length; i++) {
209: if (stdLibs[i].isUsed()) {
210: buf.append(stdLibs[i].getCmd());
211: buf.append(" "); // NOI18N
212: }
213: }
214:
215: return buf.toString();
216: }
217:
218: private String indent = new String(" "); // NOI18N
219:
220: /** Default dump has no indent */
221: protected void dump() {
222: println(" stdLibFlags = {"); // NOI18N
223: println(" }\n"); // NOI18N
224: }
225:
226: /**
227: * Allow caller to indent all data. This is usefull for indenting target
228: * dumps within MakefileData dumps.
229: */
230: public void dump(String in) {
231: setIndent(in);
232: dump();
233: }
234:
235: private void println(String s) {
236: System.out.println(indent + s);
237: }
238:
239: private void setIndent(String indent) {
240: this .indent = indent;
241: }
242:
243: private ResourceBundle bundle = null;
244:
245: private String getString(String s) {
246: if (bundle == null) {
247: bundle = NbBundle.getBundle(MakefileWizardPanel.class);
248: }
249: return bundle.getString(s);
250: }
251:
252: }
|